Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(764)

Unified Diff: webkit/fileapi/file_system_util.cc

Issue 9370045: Fixed bug: we can now handle "a:b" as a file name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/fileapi/file_system_util.h ('k') | webkit/fileapi/file_system_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/fileapi/file_system_util.cc
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index e0c16a5298e958606d8466d2f3023cf193cb50f4..26c6a0fc7fd56ee6f4b399e0344acd5a4c32e034 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -92,6 +92,51 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type,
return true;
}
+//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 FilePath elsewhere [e.g. DirName and other methods may also need
+// replacement].
+FilePath VirtualPath::BaseName(const FilePath& virtual_path) {
+ FilePath::StringType path = virtual_path.value();
+
+ // Keep everything after the final separator, but if the pathname is only
+ // one character and it's a separator, leave it alone.
+ while (path.size() > 1 && FilePath::IsSeparator(path[path.size() - 1]))
+ path.resize(path.size() - 1);
+ FilePath::StringType::size_type last_separator =
+ path.find_last_of(FilePath::kSeparators);
+ if (last_separator != FilePath::StringType::npos &&
+ last_separator < path.size() - 1)
+ path.erase(0, last_separator + 1);
+
+ return FilePath(path);
+}
+
+void VirtualPath::GetComponents(
+ const FilePath& path, std::vector<FilePath::StringType>* components) {
+ DCHECK(components);
+ if (!components)
+ return;
+ components->clear();
+ if (path.value().empty())
+ return;
+
+ std::vector<FilePath::StringType> ret_val;
+ FilePath current = path;
+ FilePath base;
+
+ // Due to the way things are implemented, FilePath::DirName works here,
+ // whereas FilePath::BaseName doesn't.
+ while (current != current.DirName()) {
+ base = BaseName(current);
+ ret_val.push_back(base.value());
+ current = current.DirName();
+ }
+
+ *components =
+ std::vector<FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
+}
+
GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
std::string path("filesystem:");
path += origin_url.spec();
« no previous file with comments | « webkit/fileapi/file_system_util.h ('k') | webkit/fileapi/file_system_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698