|
|
@ -171,7 +171,7 @@ arg_to_string(JSContextRef context, JSValueRef arg, JSValueRef *exception) { |
|
|
|
* quote characters escaped. |
|
|
|
* quote characters escaped. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static char * |
|
|
|
static char * |
|
|
|
escape(const gchar *text) { |
|
|
|
escape(const gchar *text) { |
|
|
|
gchar *escaped; |
|
|
|
gchar *escaped; |
|
|
|
gchar **split; |
|
|
|
gchar **split; |
|
|
|
gchar *result; |
|
|
|
gchar *result; |
|
|
@ -1137,13 +1137,15 @@ get_conf_bool_cb(JSContextRef context, |
|
|
|
return JSValueMakeBoolean(context, value); |
|
|
|
return JSValueMakeBoolean(context, value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static JSValueRef |
|
|
|
static JSValueRef |
|
|
|
get_dirlist_cb(JSContextRef context, |
|
|
|
get_dirlist_cb(JSContextRef context, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef function, |
|
|
|
JSObjectRef thisObject, |
|
|
|
JSObjectRef thisObject, |
|
|
|
size_t argumentCount, |
|
|
|
size_t argumentCount, |
|
|
|
const JSValueRef arguments[], |
|
|
|
const JSValueRef arguments[], |
|
|
|
JSValueRef *exception) { |
|
|
|
JSValueRef *exception) { |
|
|
|
|
|
|
|
|
|
|
|
JSObjectRef array; |
|
|
|
JSObjectRef array; |
|
|
|
guint n_entries = 0; |
|
|
|
guint n_entries = 0; |
|
|
|
JSValueRef *args = NULL; |
|
|
|
JSValueRef *args = NULL; |
|
|
@ -1157,11 +1159,12 @@ get_dirlist_cb(JSContextRef context, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
path = arg_to_string(context, arguments[0], exception); |
|
|
|
path = arg_to_string(context, arguments[0], exception); |
|
|
|
|
|
|
|
|
|
|
|
if (!path) { |
|
|
|
if (!path) { |
|
|
|
return JSValueMakeNull(context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dir = g_dir_open (path, 0, &err); |
|
|
|
dir = g_dir_open(path, 0, &err); |
|
|
|
|
|
|
|
|
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
_mkexception(context, exception, err->message); |
|
|
|
_mkexception(context, exception, err->message); |
|
|
@ -1170,23 +1173,24 @@ get_dirlist_cb(JSContextRef context, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Create the lis of the directory entries |
|
|
|
* Create the list of the directory entries |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
while ( ( dirent = g_dir_read_name(dir) ) != NULL) { |
|
|
|
while ((dirent = g_dir_read_name (dir)) != NULL) { |
|
|
|
|
|
|
|
n_entries++; |
|
|
|
n_entries++; |
|
|
|
args = g_realloc (args, sizeof (JSValueRef) * (n_entries + 1)); |
|
|
|
args = g_realloc( args, sizeof(JSValueRef) * ( n_entries + 1 ) ); |
|
|
|
fullpath = g_build_filename (path, dirent, NULL); /* Give theme developer full pathname */ |
|
|
|
fullpath = g_build_filename(path, dirent, NULL); /* Give theme developer full pathname */ |
|
|
|
args[(n_entries - 1)] = string_or_null (context, fullpath); |
|
|
|
args[( n_entries - 1 )] = string_or_null(context, fullpath); |
|
|
|
g_free (fullpath); |
|
|
|
g_free(fullpath); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
g_dir_close (dir); |
|
|
|
g_dir_close(dir); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
array = JSObjectMakeArray(context, n_entries, args, exception); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g_free(args); |
|
|
|
|
|
|
|
|
|
|
|
array = JSObjectMakeArray (context, n_entries, args, exception); |
|
|
|
|
|
|
|
g_free (args); |
|
|
|
|
|
|
|
if (array == NULL) { |
|
|
|
if (array == NULL) { |
|
|
|
return JSValueMakeNull (context); |
|
|
|
return JSValueMakeNull(context); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return array; |
|
|
|
return array; |
|
|
|
} |
|
|
|
} |
|
|
|