From d04171923e3ca975031d76fe4e7f551c33a6d0ea Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 11 Jun 2012 15:19:24 -0700 Subject: [PATCH] Only recurse for entries that are directories --- Atom-Linux/native_handler.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Atom-Linux/native_handler.cpp b/Atom-Linux/native_handler.cpp index 44a6b06bd..cd6041d98 100644 --- a/Atom-Linux/native_handler.cpp +++ b/Atom-Linux/native_handler.cpp @@ -74,15 +74,22 @@ void NativeHandler::Absolute(const CefString& name, void ListDirectory(string path, vector* paths, bool recursive) { dirent **children; int childrenCount = scandir(path.c_str(), &children, 0, alphasort); + struct stat statResult; + int result; + for (int i = 0; i < childrenCount; i++) { - if (strcmp(children[i]->d_name, ".") == 0) - continue; - if (strcmp(children[i]->d_name, "..") == 0) + if (strcmp(children[i]->d_name, ".") == 0 + || strcmp(children[i]->d_name, "..") == 0) { + free(children[i]); continue; + } string entryPath(path + "/" + children[i]->d_name); paths->push_back(entryPath); - if (recursive) - ListDirectory(entryPath, paths, recursive); + if (recursive) { + result = stat(entryPath.c_str(), &statResult); + if (result == 0 && S_ISDIR(statResult.st_mode)) + ListDirectory(entryPath, paths, recursive); + } free(children[i]); } free(children); @@ -179,7 +186,6 @@ void NativeHandler::ReadFromPasteboard(const CefString& name, bool NativeHandler::Execute(const CefString& name, CefRefPtr object, const CefV8ValueList& arguments, CefRefPtr& retval, CefString& exception) { - if (name == "exists") Exists(name, object, arguments, retval, exception); else if (name == "read")