Skip to content
Snippets Groups Projects
Commit 3a0f8b61 authored by rswindell's avatar rswindell
Browse files

Work-around for Borland CRTL bug with utime(fname, NULL), sets file time

stamps to UTC instead of local time: passing a struct utimbuf fixes it.
parent 9c70d8de
No related branches found
No related tags found
No related merge requests found
...@@ -2573,8 +2573,7 @@ js_utime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -2573,8 +2573,7 @@ js_utime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
char* fname; char* fname;
int32 actime; int32 actime;
int32 modtime; int32 modtime;
struct utimbuf tbuf; struct utimbuf ut;
struct utimbuf* t=NULL;
if(JSVAL_IS_VOID(argv[0])) if(JSVAL_IS_VOID(argv[0]))
return(JS_TRUE); return(JS_TRUE);
...@@ -2584,17 +2583,18 @@ js_utime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -2584,17 +2583,18 @@ js_utime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
if((fname=js_ValueToStringBytes(cx, argv[0], NULL))==NULL) if((fname=js_ValueToStringBytes(cx, argv[0], NULL))==NULL)
return(JS_FALSE); return(JS_FALSE);
/* use current time as default */
ut.actime = ut.modtime = time(NULL);
if(argc>1) { if(argc>1) {
memset(&tbuf,0,sizeof(tbuf)); actime=modtime=ut.actime;
actime=modtime=time(NULL);
JS_ValueToInt32(cx,argv[1],&actime); JS_ValueToInt32(cx,argv[1],&actime);
JS_ValueToInt32(cx,argv[2],&modtime); JS_ValueToInt32(cx,argv[2],&modtime);
tbuf.actime=actime; ut.actime=actime;
tbuf.modtime=modtime; ut.modtime=modtime;
t=&tbuf;
} }
*rval = BOOLEAN_TO_JSVAL(utime(fname,t)==0); *rval = BOOLEAN_TO_JSVAL(utime(fname,&ut)==0);
return(JS_TRUE); return(JS_TRUE);
} }
......
...@@ -111,9 +111,11 @@ FILE* fnopen(int* fd, const char* str, int access) ...@@ -111,9 +111,11 @@ FILE* fnopen(int* fd, const char* str, int access)
BOOL ftouch(const char* fname) BOOL ftouch(const char* fname)
{ {
int file; int file;
struct utimbuf ut;
/* update the time stamp */ /* update the time stamp */
if(utime(fname, /* use current date/time: */NULL)==0) ut.actime = ut.modtime = time(NULL);
if(utime(fname, &ut)==0)
return(TRUE); return(TRUE);
/* create the file */ /* create the file */
......
...@@ -126,6 +126,7 @@ void DLLCALL semfile_list_free(str_list_t* filelist) ...@@ -126,6 +126,7 @@ void DLLCALL semfile_list_free(str_list_t* filelist)
BOOL DLLCALL semfile_signal(const char* fname, const char* text) BOOL DLLCALL semfile_signal(const char* fname, const char* text)
{ {
int file; int file;
struct utimbuf ut;
#if !defined(NO_SOCKET_SUPPORT) #if !defined(NO_SOCKET_SUPPORT)
char hostname[128]; char hostname[128];
...@@ -138,5 +139,7 @@ BOOL DLLCALL semfile_signal(const char* fname, const char* text) ...@@ -138,5 +139,7 @@ BOOL DLLCALL semfile_signal(const char* fname, const char* text)
write(file,text,strlen(text)); write(file,text,strlen(text));
close(file); close(file);
return utime(fname, /* use current date/time: */NULL)==0; /* update the time stamp */
ut.actime = ut.modtime = time(NULL);
return utime(fname, &ut)==0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment