Skip to content
Snippets Groups Projects
Commit 69f08a3f authored by rswindell's avatar rswindell
Browse files

New global method: file_cdate() to get a file's creation time.

parent f09b6915
Branches
Tags
No related merge requests found
......@@ -3174,6 +3174,32 @@ js_fdate(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
}
static JSBool
js_fcdate(JSContext *cx, uintN argc, jsval *arglist)
{
jsval *argv=JS_ARGV(cx, arglist);
char* p;
time_t fd;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc==0 || JSVAL_IS_VOID(argv[0]))
return(JS_TRUE);
JSVALUE_TO_MSTRING(cx, argv[0], p, NULL)
HANDLE_PENDING(cx);
if(p==NULL)
return(JS_TRUE);
rc=JS_SUSPENDREQUEST(cx);
fd=fcdate(p);
free(p);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist,DOUBLE_TO_JSVAL((double)fd));
return(JS_TRUE);
}
static JSBool
js_utime(JSContext *cx, uintN argc, jsval *arglist)
{
......@@ -4143,6 +4169,10 @@ static jsSyncMethodSpec js_global_functions[] = {
,JSDOCSTR("get a file's last modified date/time (in time_t format)")
,310
},
{"file_cdate", js_fcdate, 1, JSTYPE_NUMBER, JSDOCSTR("path/filename")
,JSDOCSTR("get a file's creation date/time (in time_t format)")
,317
},
{"file_size", js_flength, 1, JSTYPE_NUMBER, JSDOCSTR("path/filename")
,JSDOCSTR("get a file's length (in bytes)")
,310
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment