mirror of
https://github.com/atom/atom.git
synced 2026-01-22 21:38:10 -05:00
Remove unused $native.traverseTree()
This commit is contained in:
@@ -24,7 +24,7 @@ namespace v8_extensions {
|
||||
|
||||
void Native::CreateContextBinding(CefRefPtr<CefV8Context> context) {
|
||||
const char* methodNames[] = {
|
||||
"exists", "read", "write", "absolute", "traverseTree", "isDirectory",
|
||||
"exists", "read", "write", "absolute", "isDirectory",
|
||||
"isFile", "remove", "writeToPasteboard", "readFromPasteboard", "quit", "watchPath", "unwatchPath",
|
||||
"getWatchedPaths", "unwatchAllPaths", "makeDirectory", "move", "moveToTrash", "reload", "lastModified",
|
||||
"md5ForPath", "getPlatform", "setWindowState", "getWindowState", "isMisspelled",
|
||||
@@ -113,52 +113,6 @@ namespace v8_extensions {
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "traverseTree") {
|
||||
std::string argument = arguments[0]->GetStringValue().ToString();
|
||||
int rootPathLength = argument.size() + 1;
|
||||
char rootPath[rootPathLength];
|
||||
strcpy(rootPath, argument.c_str());
|
||||
char * const paths[] = {rootPath, NULL};
|
||||
|
||||
FTS *tree = fts_open(paths, FTS_COMFOLLOW | FTS_PHYSICAL| FTS_NOCHDIR | FTS_NOSTAT, NULL);
|
||||
if (tree == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> onFile = arguments[1];
|
||||
CefRefPtr<CefV8Value> onDir = arguments[2];
|
||||
CefV8ValueList args;
|
||||
FTSENT *entry;
|
||||
while ((entry = fts_read(tree)) != NULL) {
|
||||
if (entry->fts_level == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isFile = entry->fts_info == FTS_NSOK;
|
||||
bool isDir = entry->fts_info == FTS_D;
|
||||
if (!isFile && !isDir) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int pathLength = entry->fts_pathlen - rootPathLength;
|
||||
char relative[pathLength + 1];
|
||||
relative[pathLength] = '\0';
|
||||
strncpy(relative, entry->fts_path + rootPathLength, pathLength);
|
||||
args.clear();
|
||||
args.push_back(CefV8Value::CreateString(relative));
|
||||
if (isFile) {
|
||||
onFile->ExecuteFunction(onFile, args);
|
||||
}
|
||||
else {
|
||||
CefRefPtr<CefV8Value> enterDir = onDir->ExecuteFunction(onDir, args);
|
||||
if(enterDir != NULL && !enterDir->GetBoolValue()) {
|
||||
fts_set(tree, entry, FTS_SKIP);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "isDirectory") {
|
||||
NSString *path = stringFromCefV8Value(arguments[0]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user