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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_util.h" 5 #include "webkit/fileapi/file_system_util.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 *origin_url = origin; 85 *origin_url = origin;
86 if (type) 86 if (type)
87 *type = file_system_type; 87 *type = file_system_type;
88 if (file_path) 88 if (file_path)
89 *file_path = FilePath::FromUTF8Unsafe(path). 89 *file_path = FilePath::FromUTF8Unsafe(path).
90 NormalizePathSeparators().StripTrailingSeparators(); 90 NormalizePathSeparators().StripTrailingSeparators();
91 91
92 return true; 92 return true;
93 } 93 }
94 94
95 //TODO(ericu): Consider removing support for '\', even on Windows, if possible.
96 // There's a lot of test code that will need reworking, and we may have trouble
97 // with FilePath elsewhere [e.g. DirName and other methods may also need
98 // replacement].
99 FilePath VirtualPath::BaseName(const FilePath& virtual_path) {
100 FilePath::StringType path = virtual_path.value();
101
102 // Keep everything after the final separator, but if the pathname is only
103 // one character and it's a separator, leave it alone.
104 while (path.size() > 1 && FilePath::IsSeparator(path[path.size() - 1]))
105 path.resize(path.size() - 1);
106 FilePath::StringType::size_type last_separator =
107 path.find_last_of(FilePath::kSeparators);
108 if (last_separator != FilePath::StringType::npos &&
109 last_separator < path.size() - 1)
110 path.erase(0, last_separator + 1);
111
112 return FilePath(path);
113 }
114
115 void VirtualPath::GetComponents(
116 const FilePath& path, std::vector<FilePath::StringType>* components) {
117 DCHECK(components);
118 if (!components)
119 return;
120 components->clear();
121 if (path.value().empty())
122 return;
123
124 std::vector<FilePath::StringType> ret_val;
125 FilePath current = path;
126 FilePath base;
127
128 // Due to the way things are implemented, FilePath::DirName works here,
129 // whereas FilePath::BaseName doesn't.
130 while (current != current.DirName()) {
131 base = BaseName(current);
132 ret_val.push_back(base.value());
133 current = current.DirName();
134 }
135
136 *components =
137 std::vector<FilePath::StringType>(ret_val.rbegin(), ret_val.rend());
138 }
139
95 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) { 140 GURL GetFileSystemRootURI(const GURL& origin_url, FileSystemType type) {
96 std::string path("filesystem:"); 141 std::string path("filesystem:");
97 path += origin_url.spec(); 142 path += origin_url.spec();
98 switch (type) { 143 switch (type) {
99 case kFileSystemTypeTemporary: 144 case kFileSystemTypeTemporary:
100 path += (kTemporaryDir + 1); // We don't want the leading slash. 145 path += (kTemporaryDir + 1); // We don't want the leading slash.
101 break; 146 break;
102 case kFileSystemTypePersistent: 147 case kFileSystemTypePersistent:
103 path += (kPersistentDir + 1); // We don't want the leading slash. 148 path += (kPersistentDir + 1); // We don't want the leading slash.
104 break; 149 break;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 return fileapi::kPersistentName; 217 return fileapi::kPersistentName;
173 case kFileSystemTypeExternal: 218 case kFileSystemTypeExternal:
174 return fileapi::kExternalName; 219 return fileapi::kExternalName;
175 case kFileSystemTypeUnknown: 220 case kFileSystemTypeUnknown:
176 default: 221 default:
177 return std::string(); 222 return std::string();
178 } 223 }
179 } 224 }
180 225
181 } // namespace fileapi 226 } // namespace fileapi
OLDNEW
« 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