change algorithm for 'ros roswell-internal-use version date'.

This commit is contained in:
SANO Masatoshi 2016-12-14 12:05:03 +09:00
parent ef211edf8f
commit 37d6e76abf
4 changed files with 22 additions and 10 deletions

View file

@ -62,9 +62,7 @@ DEF_SUBCMD(cmd_internal_version) {
}else if (argc==2) {
char* ev=NULL;
char* arg1=firsts(nthcdr(1,arg_));
if(strcmp(arg1,"date")==0) {
ev= "date";
}else if (strcmp(arg1,"lisp")==0) {
if (strcmp(arg1,"lisp")==0) {
ev= "version";
}else if (strcmp(arg1,"dump")==0) {
ev= "roswell";
@ -75,6 +73,12 @@ DEF_SUBCMD(cmd_internal_version) {
LVal arg=stringlist("--no-rc","-L",DEFAULT_IMPL,"-m","roswell","--eval",cmd,"run",NULL);
for(;arg;arg=dispatch(arg,&top));
s(cmd);
}else if(strncmp(arg1,"date",4)==0) {
char* impl_path=s_cat(configdir(),q("impls"SLASH),uname_m(),q(SLASH),uname(),q(SLASH DEFAULT_IMPL SLASH),
q(get_opt("sbcl-bin.version",0)),q(SLASH "dump" SLASH "roswell.core"),NULL);
cond_printf(1,"mtime of %s:%lu\n",impl_path,file_mtime(impl_path));
printf("%lu\n",2208988800+file_mtime(impl_path));
s(impl_path);
}else if(strncmp(arg1,"cc",2)==0) {
printf("%s\n",ROS_COMPILE_ENVIRONMENT);
}else if(strncmp(arg1,"curl",4)==0) {

View file

@ -29,15 +29,19 @@ void touch(char* path) {
s(cmd);
}
int file_exist_p (char* path) {
int file_exist_p(char* path) {
struct stat sb;
return (stat(path, &sb) == 0 && S_ISREG(sb.st_mode))?1:0;
}
int file_newer_p(char * a,char* b) {
struct stat as,bs;
if(stat(b, &bs) != 0)
return 1;
return (stat(a, &as) == 0 && as.st_mtime >= bs.st_mtime);
long file_mtime(char* path) {
struct stat sb;
return stat(path, &sb) == 0 ? sb.st_mtime:0;
}
int file_newer_p(char* a,char* b) {
long at=file_mtime(a),bt=file_mtime(b);
return bt==0?1:(at!=0&& at>=bt);
}
#endif

View file

@ -24,8 +24,11 @@ int file_exist_p (char* path) {
return 1;
}
int file_newer_p(char * a,char* b) {
int file_mtime(char* path) {
return 0;
}
int file_newer_p(char * a,char* b) {
return 0;
}
#endif

View file

@ -140,6 +140,7 @@ int delete_file(char* pathspec);
int rename_file(char* file,char* new_name);
void touch(char* path);
int file_exist_p (char* path);
long file_mtime(char* path);
int file_newer_p(char * a,char* b);
/*util_system.c */
char* system_(char* cmd);