summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/android/FileSystemAndroid.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-05 14:34:32 -0800
commit635860845790a19bf50bbc51ba8fb66a96dde068 (patch)
treeef6ad9ff73a5b57f65249d4232a202fa77e6a140 /WebCore/platform/android/FileSystemAndroid.cpp
parent8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (diff)
downloadexternal_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.zip
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.gz
external_webkit-635860845790a19bf50bbc51ba8fb66a96dde068.tar.bz2
auto import from //depot/cupcake/@136594
Diffstat (limited to 'WebCore/platform/android/FileSystemAndroid.cpp')
-rw-r--r--WebCore/platform/android/FileSystemAndroid.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/WebCore/platform/android/FileSystemAndroid.cpp b/WebCore/platform/android/FileSystemAndroid.cpp
index b6d58bc..fcb0413 100644
--- a/WebCore/platform/android/FileSystemAndroid.cpp
+++ b/WebCore/platform/android/FileSystemAndroid.cpp
@@ -29,7 +29,9 @@
#include "FileSystem.h"
#include "CString.h"
+#include <fnmatch.h>
#include <dlfcn.h>
+#include <dirent.h>
#include <errno.h>
#include <sys/stat.h>
#include "cutils/log.h"
@@ -98,4 +100,33 @@ String homeDirectoryPath()
return sPluginPath;
}
+// new as of webkit4, Feb 28, 2009
+Vector<String> listDirectory(const String& path, const String& filter)
+{
+ Vector<String> entries;
+ CString cpath = path.utf8();
+ CString cfilter = filter.utf8();
+ DIR* dir = opendir(cpath.data());
+ if (dir) {
+ struct dirent * dp;
+ while ((dp = readdir(dir)) != NULL) {
+ const char* name = dp->d_name;
+ if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
+ continue;
+ }
+ if (fnmatch(cfilter.data(), name, 0) != 0) {
+ continue;
+ }
+ char filePath[1024];
+ if ((int) (sizeof(filePath) - 1) < snprintf(filePath,
+ sizeof(filePath), "%s/%s", cpath.data(), name)) {
+ continue; // buffer overflow
+ }
+ entries.append(filePath);
+ }
+ closedir(dir);
+ }
+ return entries;
+}
+
}