Skip to content
Snippets Groups Projects
Commit 1b9e7ebb authored by rswindell's avatar rswindell
Browse files

Added file_remove() global function.

parent 6dd33529
No related branches found
No related tags found
No related merge requests found
......@@ -280,6 +280,27 @@ js_fexist(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_TRUE);
}
static JSBool
js_remove(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* p;
JSString* js_str;
if((js_str=JS_ValueToString(cx, argv[0]))==NULL) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return(JS_TRUE);
}
if((p=JS_GetStringBytes(js_str))==NULL) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return(JS_TRUE);
}
*rval = BOOLEAN_TO_JSVAL(remove(p)==0);
return(JS_TRUE);
}
static JSBool
js_isdir(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
......@@ -418,6 +439,7 @@ static JSFunctionSpec js_global_functions[] = {
{"ascii", js_ascii, 1}, /* convert str to ascii-val or vice-versa */
{"strip_ctrl", js_strip_ctrl, 1}, /* strip ctrl chars from string */
{"file_exists", js_fexist, 1}, /* verify file existence */
{"file_remove", js_remove, 1}, /* delete a file */
{"file_isdir", js_isdir, 1}, /* check if directory */
{"file_attrib", js_fattr, 1}, /* get file mode/attributes */
{"file_date", js_fdate, 1}, /* get file last modified date/time */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment