summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_util.cc
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/fileapi/file_system_util.cc')
-rw-r--r--webkit/fileapi/file_system_util.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index 7e017f7..9b2aae0 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -25,6 +25,9 @@ const char kIsolatedDir[] = "/isolated";
const char kExternalDir[] = "/external";
const char kTestDir[] = "/test";
+const FilePath::CharType VirtualPath::kRoot[] = FILE_PATH_LITERAL("/");
+const FilePath::CharType VirtualPath::kSeparator = FILE_PATH_LITERAL('/');
+
// TODO(ericu): Consider removing support for '\', even on Windows, if possible.
// There's a lot of test code that will need reworking, and we may have trouble
// with base::FilePath elsewhere [e.g. DirName and other methods may also need
@@ -70,6 +73,23 @@ void VirtualPath::GetComponents(
std::vector<base::FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
}
+FilePath::StringType VirtualPath::GetNormalizedFilePath(const FilePath& path) {
+ FilePath::StringType normalized_path = path.value();
+ const size_t num_separators = FilePath::StringType(
+ FilePath::kSeparators).length();
+ for (size_t i = 1; i < num_separators; ++i) {
+ std::replace(normalized_path.begin(), normalized_path.end(),
+ FilePath::kSeparators[i], kSeparator);
+ }
+
+ return (IsAbsolute(normalized_path)) ?
+ normalized_path : FilePath::StringType(kRoot) + normalized_path;
+}
+
+bool VirtualPath::IsAbsolute(const FilePath::StringType& path) {
+ return path.find(kRoot) == 0;
+}
+
GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
// origin_url is based on a security origin, so http://foo.com or file:///
// instead of the corresponding filesystem URL.