Commit a87cebdb authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Add User close() method

This can be used to force a close of the user.dat file, if open. Rather than
waiting for an out of scope User to get garbage-collected, this method could
be used to force a close of the user.dat file, if it's open.
parent 91f67dc7
......@@ -1307,6 +1307,26 @@ js_get_time_left(JSContext *cx, uintN argc, jsval *arglist)
return JS_TRUE;
static JSBool
js_user_close(JSContext *cx, uintN argc, jsval *arglist)
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
private_t* p;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if((p=(private_t*)js_GetClassPrivate(cx, obj, &js_user_class))==NULL)
return JS_FALSE;
if(p->file > 0)
p->file = -1;
return JS_TRUE;
static jsSyncMethodSpec js_user_functions[] = {
{"compare_ars", js_chk_ar, 1, JSTYPE_BOOLEAN, JSDOCSTR("string ars")
......@@ -1346,6 +1366,10 @@ static jsSyncMethodSpec js_user_functions[] = {
"Note: for the pre-defined user object on the BBS, you almost certainly want bbs.get_time_left() instead.")
{"close", js_user_close, 0, JSTYPE_VOID, JSDOCSTR("")
,JSDOCSTR("Close the <tt>user.dat</tt> file, if open. The file will be auto-reopened if necessary.")
Supports Markdown
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