summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 15:36:09 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 15:36:09 +0000
commit36cb60808422968817bb1154fcb9aaeddb6a077e (patch)
treee0f6cd62a68b03a872bfe6337a0ff9c92c281f4f /webkit
parent5d4e36df4d25cb9bc21882105065f9dcc0941e1e (diff)
downloadchromium_src-36cb60808422968817bb1154fcb9aaeddb6a077e.zip
chromium_src-36cb60808422968817bb1154fcb9aaeddb6a077e.tar.gz
chromium_src-36cb60808422968817bb1154fcb9aaeddb6a077e.tar.bz2
Revert 182604 because it breaks fast/filesystem/op-restricted-chars.html
The fast/filesystem/op-restricted-chars.html layout test started failing as of this CL. > Fix VirtualPath::GetComponents to handle drive letter string as usual path component > > Also fix the function comment as the existing code seems to handle the '.' component correctly (and so does the new code). > > BUG=none > TEST=FileSystemUtilTest.VirtualPathGetComponents > > Review URL: https://codereview.chromium.org/12253006 TBR=kinuko@chromium.org Review URL: https://codereview.chromium.org/12277003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182715 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/fileapi/file_system_util.cc26
-rw-r--r--webkit/fileapi/file_system_util.h11
-rw-r--r--webkit/fileapi/file_system_util_unittest.cc8
3 files changed, 19 insertions, 26 deletions
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index 79e2b76..24513d8 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -49,10 +49,7 @@ base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) {
}
void VirtualPath::GetComponents(
- const base::FilePath& path,
- std::vector<base::FilePath::StringType>* components) {
- typedef base::FilePath::StringType StringType;
-
+ const base::FilePath& path, std::vector<base::FilePath::StringType>* components) {
DCHECK(components);
if (!components)
return;
@@ -60,15 +57,20 @@ void VirtualPath::GetComponents(
if (path.value().empty())
return;
- StringType::size_type begin = 0, end = 0;
- while (begin < path.value().length() && end != StringType::npos) {
- end = path.value().find_first_of(base::FilePath::kSeparators, begin);
- StringType component = path.value().substr(
- begin, end == StringType::npos ? StringType::npos : end - begin);
- if (!component.empty() && component != base::FilePath::kCurrentDirectory)
- components->push_back(component);
- begin = end + 1;
+ std::vector<base::FilePath::StringType> ret_val;
+ base::FilePath current = path;
+ base::FilePath base;
+
+ // Due to the way things are implemented, base::FilePath::DirName works here,
+ // whereas base::FilePath::BaseName doesn't.
+ while (current != current.DirName()) {
+ base = BaseName(current);
+ ret_val.push_back(base.value());
+ current = current.DirName();
}
+
+ *components =
+ std::vector<base::FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
}
FilePath::StringType VirtualPath::GetNormalizedFilePath(const FilePath& path) {
diff --git a/webkit/fileapi/file_system_util.h b/webkit/fileapi/file_system_util.h
index 351f094..ffefe57 100644
--- a/webkit/fileapi/file_system_util.h
+++ b/webkit/fileapi/file_system_util.h
@@ -36,12 +36,11 @@ class WEBKIT_STORAGE_EXPORT VirtualPath {
// character.
static base::FilePath BaseName(const base::FilePath& virtual_path);
- // Likewise, use this instead of base::FilePath::GetComponents when
- // operating on virtual paths.
- // Note that this assumes very clean input, with no leading slash, and
- // it will not evaluate '..' components.
- static void GetComponents(
- const base::FilePath& path,
+ // Likewise, use this instead of base::FilePath::GetComponents when operating on
+ // virtual paths.
+ // Note that this assumes very clean input, with no leading slash, and it will
+ // not evaluate '.' or '..' components.
+ static void GetComponents(const base::FilePath& path,
std::vector<base::FilePath::StringType>* components);
// Returns a path name ensuring that it begins with kRoot and all path
diff --git a/webkit/fileapi/file_system_util_unittest.cc b/webkit/fileapi/file_system_util_unittest.cc
index 6ffe873..3bf54fb 100644
--- a/webkit/fileapi/file_system_util_unittest.cc
+++ b/webkit/fileapi/file_system_util_unittest.cc
@@ -106,14 +106,6 @@ TEST_F(FileSystemUtilTest, VirtualPathGetComponents) {
{ FILE_PATH_LITERAL("/foo/bar"),
2,
{ FILE_PATH_LITERAL("foo"), FILE_PATH_LITERAL("bar") } },
- { FILE_PATH_LITERAL("c:/bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#ifdef FILE_PATH_USES_WIN_SEPARATORS
- { FILE_PATH_LITERAL("c:\\bar"),
- 2,
- { FILE_PATH_LITERAL("c:"), FILE_PATH_LITERAL("bar") } },
-#endif
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
base::FilePath input = base::FilePath(test_cases[i].path);