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

Side by Side Diff: base/file_path.h

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 years, 3 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
« no previous file with comments | « base/debug_util_posix.cc ('k') | base/file_path.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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 // FilePath is a container for pathnames stored in a platform's native string 5 // FilePath is a container for pathnames stored in a platform's native string
6 // type, providing containers for manipulation in according with the 6 // type, providing containers for manipulation in according with the
7 // platform's conventions for pathnames. It supports the following path 7 // platform's conventions for pathnames. It supports the following path
8 // types: 8 // types:
9 // 9 //
10 // POSIX Windows 10 // POSIX Windows
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 FilePath RemoveExtension() const; 180 FilePath RemoveExtension() const;
181 181
182 // Inserts |suffix| after the file name portion of |path| but before the 182 // Inserts |suffix| after the file name portion of |path| but before the
183 // extension. Returns "" if BaseName() == "." or "..". 183 // extension. Returns "" if BaseName() == "." or "..".
184 // Examples: 184 // Examples:
185 // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg" 185 // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg"
186 // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg" 186 // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg"
187 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" 187 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)"
188 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" 188 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
189 FilePath InsertBeforeExtension(const StringType& suffix) const; 189 FilePath InsertBeforeExtension(const StringType& suffix) const;
190 FilePath InsertBeforeExtensionASCII(const StringPiece& suffix) const; 190 FilePath InsertBeforeExtensionASCII(const base::StringPiece& suffix) const;
191 191
192 // Replaces the extension of |file_name| with |extension|. If |file_name| 192 // Replaces the extension of |file_name| with |extension|. If |file_name|
193 // does not have an extension, them |extension| is added. If |extension| is 193 // does not have an extension, them |extension| is added. If |extension| is
194 // empty, then the extension is removed from |file_name|. 194 // empty, then the extension is removed from |file_name|.
195 // Returns "" if BaseName() == "." or "..". 195 // Returns "" if BaseName() == "." or "..".
196 FilePath ReplaceExtension(const StringType& extension) const; 196 FilePath ReplaceExtension(const StringType& extension) const;
197 197
198 // Returns true if the file path matches the specified extension. The test is 198 // Returns true if the file path matches the specified extension. The test is
199 // case insensitive. Don't forget the leading period if appropriate. 199 // case insensitive. Don't forget the leading period if appropriate.
200 bool MatchesExtension(const StringType& extension) const; 200 bool MatchesExtension(const StringType& extension) const;
201 201
202 // Returns a FilePath by appending a separator and the supplied path 202 // Returns a FilePath by appending a separator and the supplied path
203 // component to this object's path. Append takes care to avoid adding 203 // component to this object's path. Append takes care to avoid adding
204 // excessive separators if this object's path already ends with a separator. 204 // excessive separators if this object's path already ends with a separator.
205 // If this object's path is kCurrentDirectory, a new FilePath corresponding 205 // If this object's path is kCurrentDirectory, a new FilePath corresponding
206 // only to |component| is returned. |component| must be a relative path; 206 // only to |component| is returned. |component| must be a relative path;
207 // it is an error to pass an absolute path. 207 // it is an error to pass an absolute path.
208 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; 208 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT;
209 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; 209 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT;
210 210
211 // Although Windows StringType is std::wstring, since the encoding it uses for 211 // Although Windows StringType is std::wstring, since the encoding it uses for
212 // paths is well defined, it can handle ASCII path components as well. 212 // paths is well defined, it can handle ASCII path components as well.
213 // Mac uses UTF8, and since ASCII is a subset of that, it works there as well. 213 // Mac uses UTF8, and since ASCII is a subset of that, it works there as well.
214 // On Linux, although it can use any 8-bit encoding for paths, we assume that 214 // On Linux, although it can use any 8-bit encoding for paths, we assume that
215 // ASCII is a valid subset, regardless of the encoding, since many operating 215 // ASCII is a valid subset, regardless of the encoding, since many operating
216 // system paths will always be ASCII. 216 // system paths will always be ASCII.
217 FilePath AppendASCII(const StringPiece& component) const WARN_UNUSED_RESULT; 217 FilePath AppendASCII(const base::StringPiece& component)
218 const WARN_UNUSED_RESULT;
218 219
219 // Returns true if this FilePath contains an absolute path. On Windows, an 220 // Returns true if this FilePath contains an absolute path. On Windows, an
220 // absolute path begins with either a drive letter specification followed by 221 // absolute path begins with either a drive letter specification followed by
221 // a separator character, or with two separator characters. On POSIX 222 // a separator character, or with two separator characters. On POSIX
222 // platforms, an absolute path begins with a separator character. 223 // platforms, an absolute path begins with a separator character.
223 bool IsAbsolute() const; 224 bool IsAbsolute() const;
224 225
225 // Returns a copy of this FilePath that does not end with a trailing 226 // Returns a copy of this FilePath that does not end with a trailing
226 // separator. 227 // separator.
227 FilePath StripTrailingSeparators() const; 228 FilePath StripTrailingSeparators() const;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 namespace stdext { 280 namespace stdext {
280 281
281 inline size_t hash_value(const FilePath& f) { 282 inline size_t hash_value(const FilePath& f) {
282 return hash_value(f.value()); 283 return hash_value(f.value());
283 } 284 }
284 285
285 } // namespace stdext 286 } // namespace stdext
286 #endif // COMPILER 287 #endif // COMPILER
287 288
288 #endif // BASE_FILE_PATH_H_ 289 #endif // BASE_FILE_PATH_H_
OLDNEW
« no previous file with comments | « base/debug_util_posix.cc ('k') | base/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698