summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_util.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 02:34:18 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-15 02:34:18 +0000
commite034aa087e7df78dd37b411841148993ad03b53b (patch)
tree075029a7299cb5966924d2cb165932fe3d1144b8 /webkit/fileapi/file_system_util.cc
parenta0e6d61e05aa364aaf5b923c17ecd0a8e579f7d7 (diff)
downloadchromium_src-e034aa087e7df78dd37b411841148993ad03b53b.zip
chromium_src-e034aa087e7df78dd37b411841148993ad03b53b.tar.gz
chromium_src-e034aa087e7df78dd37b411841148993ad03b53b.tar.bz2
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 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_util.cc')
-rw-r--r--webkit/fileapi/file_system_util.cc26
1 files changed, 12 insertions, 14 deletions
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index 24513d8..79e2b76 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -49,7 +49,10 @@ base::FilePath VirtualPath::BaseName(const base::FilePath& virtual_path) {
}
void VirtualPath::GetComponents(
- const base::FilePath& path, std::vector<base::FilePath::StringType>* components) {
+ const base::FilePath& path,
+ std::vector<base::FilePath::StringType>* components) {
+ typedef base::FilePath::StringType StringType;
+
DCHECK(components);
if (!components)
return;
@@ -57,20 +60,15 @@ void VirtualPath::GetComponents(
if (path.value().empty())
return;
- 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();
+ 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;
}
-
- *components =
- std::vector<base::FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
}
FilePath::StringType VirtualPath::GetNormalizedFilePath(const FilePath& path) {