Skip to content
Snippets Groups Projects
Commit 6e092180 authored by rswindell's avatar rswindell
Browse files

Created global function: file_compare(file1, file2)

parent 2df8e5a0
No related branches found
No related tags found
No related merge requests found
...@@ -2480,6 +2480,25 @@ js_fcopy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ...@@ -2480,6 +2480,25 @@ js_fcopy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_TRUE); return(JS_TRUE);
} }
static JSBool
js_fcompare(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* fn1;
char* fn2;
if(JSVAL_IS_VOID(argv[0]))
return(JS_TRUE);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
if((fn1=js_ValueToStringBytes(cx, argv[0], NULL))==NULL)
return(JS_TRUE);
if((fn2=js_ValueToStringBytes(cx, argv[1], NULL))==NULL)
return(JS_TRUE);
*rval = BOOLEAN_TO_JSVAL(fcompare(fn1,fn2));
return(JS_TRUE);
}
static JSBool static JSBool
js_backup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) js_backup(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{ {
...@@ -3213,6 +3232,10 @@ static jsSyncMethodSpec js_global_functions[] = { ...@@ -3213,6 +3232,10 @@ static jsSyncMethodSpec js_global_functions[] = {
"it is presumed stale and removed/over-written") "it is presumed stale and removed/over-written")
,312 ,312
}, },
{"file_compare", js_fcompare, 2, JSTYPE_BOOLEAN, JSDOCSTR("path/file1, path/file2")
,JSDOCSTR("compare 2 files, returning <i>true</i> if they are identical, <i>false</i> otherwise")
,314
},
{"directory", js_directory, 1, JSTYPE_ARRAY, JSDOCSTR("path/pattern [,flags=<tt>GLOB_MARK</tt>]") {"directory", js_directory, 1, JSTYPE_ARRAY, JSDOCSTR("path/pattern [,flags=<tt>GLOB_MARK</tt>]")
,JSDOCSTR("returns an array of directory entries, " ,JSDOCSTR("returns an array of directory entries, "
"<i>pattern</i> is the path and filename or wildcards to search for (e.g. '/subdir/*.txt'), " "<i>pattern</i> is the path and filename or wildcards to search for (e.g. '/subdir/*.txt'), "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment