diff options
author | Shimeng (Simon) Wang <swang@google.com> | 2010-12-07 17:22:45 -0800 |
---|---|---|
committer | Shimeng (Simon) Wang <swang@google.com> | 2010-12-22 14:15:40 -0800 |
commit | 4576aa36e9a9671459299c7963ac95aa94beaea9 (patch) | |
tree | 3863574e050f168c0126ecb47c83319fab0972d8 /WebCore/platform/wince | |
parent | 55323ac613cc31553107b68603cb627264d22bb0 (diff) | |
download | external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.zip external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.gz external_webkit-4576aa36e9a9671459299c7963ac95aa94beaea9.tar.bz2 |
Merge WebKit at r73109: Initial merge by git.
Change-Id: I61f1a66d9642e3d8405d3ac6ccab2a53421c75d8
Diffstat (limited to 'WebCore/platform/wince')
-rw-r--r-- | WebCore/platform/wince/FileSystemWinCE.cpp | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/WebCore/platform/wince/FileSystemWinCE.cpp b/WebCore/platform/wince/FileSystemWinCE.cpp index 90b278e..49acf12 100644 --- a/WebCore/platform/wince/FileSystemWinCE.cpp +++ b/WebCore/platform/wince/FileSystemWinCE.cpp @@ -33,13 +33,26 @@ #include "NotImplemented.h" #include "PlatformString.h" -#include <wtf/text/CString.h> - -#include <windows.h> #include <wincrypt.h> +#include <windows.h> +#include <wtf/text/CString.h> namespace WebCore { +static size_t reverseFindPathSeparator(const String& path, unsigned start = UINT_MAX) +{ + size_t positionSlash = path.reverseFind('/', start); + size_t positionBackslash = path.reverseFind('\\', start); + + if (positionSlash == notFound) + return positionBackslash; + + if (positionBackslash == notFound) + return positionSlash; + + return std::max(positionSlash, positionBackslash); +} + static bool getFileInfo(const String& path, BY_HANDLE_FILE_INFORMATION& fileInfo) { String filename = path; @@ -133,14 +146,14 @@ CString fileSystemRepresentation(const String&) bool makeAllDirectories(const String& path) { - int lastDivPos = std::max(path.reverseFind('/'), path.reverseFind('\\')); - int endPos = path.length(); - if (lastDivPos == path.length() - 1) { - endPos -= 1; - lastDivPos = std::max(path.reverseFind('/', lastDivPos), path.reverseFind('\\', lastDivPos)); + size_t lastDivPos = reverseFindPathSeparator(path); + unsigned endPos = path.length(); + if (lastDivPos == endPos - 1) { + --endPos; + lastDivPos = reverseFindPathSeparator(path, lastDivPos); } - if (lastDivPos > 0) { + if (lastDivPos != notFound) { if (!makeAllDirectories(path.substring(0, lastDivPos))) return false; } @@ -160,13 +173,18 @@ String homeDirectoryPath() String pathGetFileName(const String& path) { - return path.substring(std::max(path.reverseFind('/'), path.reverseFind('\\')) + 1); + size_t pos = reverseFindPathSeparator(path); + if (pos == notFound) + return path; + return path.substring(pos + 1); } String directoryName(const String& path) { - notImplemented(); - return String(); + size_t pos = reverseFindPathSeparator(path); + if (pos == notFound) + return String(); + return path.left(pos); } CString openTemporaryFile(const char*, PlatformFileHandle& handle) |