Skip to content
Snippets Groups Projects
Commit 2120f4be authored by rswindell's avatar rswindell
Browse files

Created global chdir() method.

parent bec4eefe
Branches
Tags
No related merge requests found
......@@ -380,6 +380,20 @@ js_prompt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return(JS_TRUE);
}
static JSBool
js_chdir(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
char* p;
if((p=JS_GetStringBytes(JS_ValueToString(cx, argv[0])))==NULL) {
*rval = INT_TO_JSVAL(-1);
return(JS_TRUE);
}
*rval = BOOLEAN_TO_JSVAL(chdir(p)==0);
return(JS_TRUE);
}
static jsSyncMethodSpec js_global_functions[] = {
{"log", js_log, 1},
{"read", js_read, 1},
......@@ -391,6 +405,7 @@ static jsSyncMethodSpec js_global_functions[] = {
{"alert", js_alert, 1},
{"prompt", js_prompt, 1},
{"confirm", js_confirm, 1},
{"chdir", js_chdir, 1},
{0}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment