Title: [121300] trunk/Source/WebCore
- Revision
- 121300
- Author
- [email protected]
- Date
- 2012-06-26 16:39:57 -0700 (Tue, 26 Jun 2012)
Log Message
[EFL] Use eina_file_ls() in EFL implementation of FileSystem listDirectory()
https://bugs.webkit.org/show_bug.cgi?id=89976
Patch by Christophe Dumez <[email protected]> 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (121299 => 121300)
--- trunk/Source/WebCore/ChangeLog 2012-06-26 23:34:21 UTC (rev 121299)
+++ trunk/Source/WebCore/ChangeLog 2012-06-26 23:39:57 UTC (rev 121300)
@@ -1,3 +1,19 @@
+2012-06-26 Christophe Dumez <[email protected]>
+
+ [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 <[email protected]>
Crash at WebCore::TextIterator::handleTextBox
Modified: trunk/Source/WebCore/platform/efl/FileSystemEfl.cpp (121299 => 121300)
--- trunk/Source/WebCore/platform/efl/FileSystemEfl.cpp 2012-06-26 23:34:21 UTC (rev 121299)
+++ trunk/Source/WebCore/platform/efl/FileSystemEfl.cpp 2012-06-26 23:39:57 UTC (rev 121300)
@@ -86,50 +86,19 @@
Vector<String> listDirectory(const String& path, const String& filter)
{
- Vector<String> entries;
- CString cpath = path.utf8();
+ Vector<String> 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;
}
}
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes