From 8e978ecd51fe0ca72113f024e6c8fb2ce4d23bdc Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Tue, 26 Jun 2012 23:39:57 +0000 Subject: [PATCH] [EFL] Use eina_file_ls() in EFL implementation of FileSystem listDirectory() https://bugs.webkit.org/show_bug.cgi?id=89976 Patch by Christophe Dumez on 2012-06-26 Reviewed by Antonio Gomes. Rewrite EFL implementation of Filesystem listDirectory() in order to use eina_file_ls() instead of POSIX C functions. This results in shorter code. No new tests, behavior has not changed. * platform/efl/FileSystemEfl.cpp: (WebCore::listDirectory): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121300 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 16 +++++++++ Source/WebCore/platform/efl/FileSystemEfl.cpp | 49 +++++---------------------- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index eaea708..2ef2d39 100755 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2012-06-26 Christophe Dumez + + [EFL] Use eina_file_ls() in EFL implementation of FileSystem listDirectory() + https://bugs.webkit.org/show_bug.cgi?id=89976 + + Reviewed by Antonio Gomes. + + Rewrite EFL implementation of Filesystem listDirectory() in order to + use eina_file_ls() instead of POSIX C functions. This results in + shorter code. + + No new tests, behavior has not changed. + + * platform/efl/FileSystemEfl.cpp: + (WebCore::listDirectory): + 2012-06-26 Alice Cheng Crash at WebCore::TextIterator::handleTextBox diff --git a/Source/WebCore/platform/efl/FileSystemEfl.cpp b/Source/WebCore/platform/efl/FileSystemEfl.cpp index d4adb16..c6bff15 100644 --- a/Source/WebCore/platform/efl/FileSystemEfl.cpp +++ b/Source/WebCore/platform/efl/FileSystemEfl.cpp @@ -86,50 +86,19 @@ String homeDirectoryPath() Vector listDirectory(const String& path, const String& filter) { - Vector entries; - CString cpath = path.utf8(); + Vector matchingEntries; CString cfilter = filter.utf8(); - char filePath[PATH_MAX]; - char* fileName; - size_t fileNameSpace; - DIR* dir; + const char *f_name; - if (cpath.length() + NAME_MAX >= sizeof(filePath)) - return entries; - // loop invariant: directory part + '/' - memcpy(filePath, cpath.data(), cpath.length()); - fileName = filePath + cpath.length(); - if (cpath.length() > 0 && filePath[cpath.length() - 1] != '/') { - fileName[0] = '/'; - fileName++; + Eina_Iterator* it = eina_file_ls(path.utf8().data()); + EINA_ITERATOR_FOREACH(it, f_name) { + if (!fnmatch(cfilter.data(), f_name, 0)) + matchingEntries.append(String::fromUTF8(f_name)); + eina_stringshare_del(f_name); } - fileNameSpace = sizeof(filePath) - (fileName - filePath) - 1; + eina_iterator_free(it); - dir = opendir(cpath.data()); - if (!dir) - return entries; - - struct dirent* de; - while (de = readdir(dir)) { - size_t nameLen; - if (de->d_name[0] == '.') { - if (de->d_name[1] == '\0') - continue; - if (de->d_name[1] == '.' && de->d_name[2] == '\0') - continue; - } - if (fnmatch(cfilter.data(), de->d_name, 0)) - continue; - - nameLen = strlen(de->d_name); - if (nameLen >= fileNameSpace) - continue; // maybe assert? it should never happen anyway... - - memcpy(fileName, de->d_name, nameLen + 1); - entries.append(filePath); - } - closedir(dir); - return entries; + return matchingEntries; } } -- 2.7.4