diff options
Diffstat (limited to 'WebCore/platform/posix/FileSystemPOSIX.cpp')
-rw-r--r-- | WebCore/platform/posix/FileSystemPOSIX.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/WebCore/platform/posix/FileSystemPOSIX.cpp b/WebCore/platform/posix/FileSystemPOSIX.cpp index 84e731d..82ae087 100644 --- a/WebCore/platform/posix/FileSystemPOSIX.cpp +++ b/WebCore/platform/posix/FileSystemPOSIX.cpp @@ -30,9 +30,16 @@ #include "FileSystem.h" #include "CString.h" +#include "NotImplemented.h" #include "PlatformString.h" #include <sys/stat.h> +#ifdef ANDROID_PLUGINS +#include <sys/types.h> +#include <dirent.h> +#include <fnmatch.h> +#endif +#include <libgen.h> #include <unistd.h> namespace WebCore { @@ -141,4 +148,46 @@ bool makeAllDirectories(const String& path) return true; } +String pathGetFileName(const String& path) +{ + return path.substring(path.reverseFind('/') + 1); +} + +String directoryName(const String& path) +{ + CString fsRep = fileSystemRepresentation(path); + + if (!fsRep.data() || fsRep.data()[0] == '\0') + return String(); + + return dirname(fsRep.mutableData()); +} + +Vector<String> listDirectory(const String& path, const String& filter) +{ +#ifdef ANDROID_PLUGINS + CString fsRepPath = fileSystemRepresentation(path); + CString fsRepFilter = fileSystemRepresentation(filter); +#endif + Vector<String> entries; +#ifdef ANDROID_PLUGINS + DIR *dir = opendir(fsRepPath.data()); + if (dir == NULL) + return entries; + for (;;) { + struct dirent *entry = readdir(dir); + if (entry == NULL) + break; + if (!fnmatch(fsRepFilter.data(), entry->d_name, FNM_NOESCAPE)) { + String fullPath = path + "/" + entry->d_name; + entries.append(fullPath); + } + } + closedir(dir); +#else + notImplemented(); +#endif + return entries; +} + } // namespace WebCore |