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
......@@ -2573,8 +2573,7 @@ js_utime(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
char* fname;
int32 actime;
int32 modtime;
struct utimbuf tbuf;
struct utimbuf* t=NULL;
struct utimbuf ut;
if(JSVAL_IS_VOID(argv[0]))
return(JS_TRUE);
......@@ -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)
return(JS_FALSE);
/* use current time as default */
ut.actime = ut.modtime = time(NULL);
if(argc>1) {
memset(&tbuf,0,sizeof(tbuf));
actime=modtime=time(NULL);
actime=modtime=ut.actime;
JS_ValueToInt32(cx,argv[1],&actime);
JS_ValueToInt32(cx,argv[2],&modtime);
tbuf.actime=actime;
tbuf.modtime=modtime;
t=&tbuf;
ut.actime=actime;
ut.modtime=modtime;
}
*rval = BOOLEAN_TO_JSVAL(utime(fname,t)==0);
*rval = BOOLEAN_TO_JSVAL(utime(fname,&ut)==0);
return(JS_TRUE);
}
......
......@@ -111,9 +111,11 @@ FILE* fnopen(int* fd, const char* str, int access)
BOOL ftouch(const char* fname)
{
int file;
struct utimbuf ut;
/* 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);
/* create the file */
......
......@@ -126,6 +126,7 @@ void DLLCALL semfile_list_free(str_list_t* filelist)
BOOL DLLCALL semfile_signal(const char* fname, const char* text)
{
int file;
struct utimbuf ut;
#if !defined(NO_SOCKET_SUPPORT)
char hostname[128];
......@@ -138,5 +139,7 @@ BOOL DLLCALL semfile_signal(const char* fname, const char* text)
write(file,text,strlen(text));
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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment