Commit 536b7e22 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Add bbs.export_filelist() method

This is the last thing needed to complete the new temp/archive menu module implemented in JavaScript for v3.19.

File list generation can easily be done in JS (see filelist.js for example), but since we have this function already in C++ (i.e. for including filelists in QWK packets) - might as well make it available for use in JS.
parent a52b17c6
Pipeline #2318 passed with stage
in 8 minutes
......@@ -3458,6 +3458,38 @@ js_getfilespec(JSContext *cx, uintN argc, jsval *arglist)
static JSBool
js_export_filelist(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
uint32 mode=0;
char* fname=NULL;
JSString* js_str;
sbbs_t* sbbs;
jsrefcount rc;
if((sbbs=js_GetPrivate(cx, JS_THIS_OBJECT(cx, arglist)))==NULL)
return JS_FALSE;
uintN argn = 0;
js_str = JS_ValueToString(cx, argv[argn]);
JSSTRING_TO_MSTRING(cx, js_str, fname, NULL);
HANDLE_PENDING(cx, fname);
if(JSVAL_IS_NUMBER(argv[argn])) {
if(!JS_ValueToECMAUint32(cx, argv[argn], &mode)) {
return JS_FALSE;
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(sbbs->create_filelist(fname, mode)));
return JS_TRUE;
static JSBool
js_listfiles(JSContext *cx, uintN argc, jsval *arglist)
......@@ -4449,6 +4481,10 @@ static jsSyncMethodSpec js_bbs_functions[] = {
"specified by number or internal code")
{"export_filelist", js_export_filelist, 2, JSTYPE_NUMBER, JSDOCSTR("filename [,mode=<tt>FL_NONE</tt>]")
,JSDOCSTR("export list of files to a text file, optionally specifying a file list mode (e.g. <tt>FL_ULTIME</tt>), returning the number of files listed")
{"list_files", js_listfiles, 1, JSTYPE_NUMBER, JSDOCSTR("[directory=<i>current</i>] [,filespec=<tt>\"*.*\"</tt> or search_string] [,mode=<tt>FL_NONE</tt>]")
,JSDOCSTR("list files in the specified file directory, "
"optionally specifying a file specification (wildcards) or a description search string, "
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