mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2025-01-07 23:59:22 +03:00
Remove native.list
Use native.traverseTree instead from fs.list and fs.listTree
This commit is contained in:
parent
7fd06c8e66
commit
a1f9e061bc
@ -13,9 +13,6 @@ var $native = {};
|
||||
native function absolute(path);
|
||||
$native.absolute = absolute;
|
||||
|
||||
native function list(path, recursive);
|
||||
$native.list = list;
|
||||
|
||||
native function traverseTree(path, onFile, onDirectory);
|
||||
$native.traverseTree = traverseTree;
|
||||
|
||||
|
@ -137,36 +137,6 @@ bool Native::Execute(const CefString& name,
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "list") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
bool recursive = arguments[1]->GetBoolValue();
|
||||
|
||||
if (!path or [path length] == 0) {
|
||||
exception = "$native.list requires a path argument";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string argument = arguments[0]->GetStringValue().ToString();
|
||||
char rootPath[argument.size() + 1];
|
||||
strcpy(rootPath, argument.c_str());
|
||||
char * const paths[] = {rootPath, NULL};
|
||||
FTS *tree = fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR | FTS_NOSTAT, NULL);
|
||||
retval = CefV8Value::CreateArray(0);
|
||||
int index = 0;
|
||||
if (tree != NULL) {
|
||||
FTSENT *entry;
|
||||
while ((entry = fts_read(tree)) != NULL) {
|
||||
if (entry->fts_level == 0)
|
||||
continue;
|
||||
if (!recursive)
|
||||
fts_set(tree, entry, FTS_SKIP);
|
||||
if (entry->fts_info == FTS_D || entry->fts_info == FTS_NSOK)
|
||||
retval->SetValue(index++, CefV8Value::CreateString(entry->fts_path));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "isDirectory") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
|
||||
|
@ -60,11 +60,21 @@ module.exports =
|
||||
|
||||
# Returns an array with all the names of files contained
|
||||
# in the directory path.
|
||||
list: (path) ->
|
||||
$native.list(path, false)
|
||||
list: (rootPath) ->
|
||||
paths = []
|
||||
onPath = (path) =>
|
||||
paths.push(@join(rootPath, path))
|
||||
false
|
||||
@traverseTree(rootPath, onPath, onPath)
|
||||
paths
|
||||
|
||||
listTree: (path) ->
|
||||
$native.list(path, true)
|
||||
listTree: (rootPath) ->
|
||||
paths = []
|
||||
onPath = (path) =>
|
||||
paths.push(@join(rootPath, path))
|
||||
true
|
||||
@traverseTree(rootPath, onPath, onPath)
|
||||
paths
|
||||
|
||||
move: (source, target) ->
|
||||
$native.move(source, target)
|
||||
|
Loading…
Reference in New Issue
Block a user