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

Side by Side Diff: base/file_path.h

Issue 10067002: Add an AddExtension() method in FilePath (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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 | « no previous file | 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) 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 // 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Examples: 235 // Examples:
236 // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg" 236 // path == "C:\pics\jojo.jpg" suffix == " (1)", returns "C:\pics\jojo (1).jpg"
237 // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg" 237 // path == "jojo.jpg" suffix == " (1)", returns "jojo (1).jpg"
238 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" 238 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)"
239 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" 239 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)"
240 FilePath InsertBeforeExtension( 240 FilePath InsertBeforeExtension(
241 const StringType& suffix) const WARN_UNUSED_RESULT; 241 const StringType& suffix) const WARN_UNUSED_RESULT;
242 FilePath InsertBeforeExtensionASCII( 242 FilePath InsertBeforeExtensionASCII(
243 const base::StringPiece& suffix) const WARN_UNUSED_RESULT; 243 const base::StringPiece& suffix) const WARN_UNUSED_RESULT;
244 244
245 // Adds |extension| to |file_name|. Returns the current FilePath if
246 // |extension| is empty. Returns "" if BaseName() == "." or "..".
247 FilePath AddExtension(
Mark Mentovai 2012/04/16 15:54:45 It’s hard to see why you need to use this without
Devlin 2012/04/17 21:52:49 The most common instance I've encountered is when
248 const StringType& extension) const WARN_UNUSED_RESULT;
249
245 // Replaces the extension of |file_name| with |extension|. If |file_name| 250 // Replaces the extension of |file_name| with |extension|. If |file_name|
246 // does not have an extension, them |extension| is added. If |extension| is 251 // does not have an extension, then |extension| is added. If |extension| is
247 // empty, then the extension is removed from |file_name|. 252 // empty, then the extension is removed from |file_name|.
248 // Returns "" if BaseName() == "." or "..". 253 // Returns "" if BaseName() == "." or "..".
249 FilePath ReplaceExtension( 254 FilePath ReplaceExtension(
250 const StringType& extension) const WARN_UNUSED_RESULT; 255 const StringType& extension) const WARN_UNUSED_RESULT;
251 256
257 // Returns true if BaseName() is "", ".", or "..".
258 bool IsBaseEmptyOrSpecialCase() const;
Mark Mentovai 2012/04/16 15:54:45 Why do you need to expose this?
Devlin 2012/04/17 21:52:49 My original thought was that these instances are f
Mark Mentovai 2012/04/18 20:02:21 D Cronin wrote:
Devlin 2012/04/19 00:05:42 Done.
259
252 // Returns true if the file path matches the specified extension. The test is 260 // Returns true if the file path matches the specified extension. The test is
253 // case insensitive. Don't forget the leading period if appropriate. 261 // case insensitive. Don't forget the leading period if appropriate.
254 bool MatchesExtension(const StringType& extension) const; 262 bool MatchesExtension(const StringType& extension) const;
255 263
256 // Returns a FilePath by appending a separator and the supplied path 264 // Returns a FilePath by appending a separator and the supplied path
257 // component to this object's path. Append takes care to avoid adding 265 // component to this object's path. Append takes care to avoid adding
258 // excessive separators if this object's path already ends with a separator. 266 // excessive separators if this object's path already ends with a separator.
259 // If this object's path is kCurrentDirectory, a new FilePath corresponding 267 // If this object's path is kCurrentDirectory, a new FilePath corresponding
260 // only to |component| is returned. |component| must be a relative path; 268 // only to |component| is returned. |component| must be a relative path;
261 // it is an error to pass an absolute path. 269 // it is an error to pass an absolute path.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 428
421 inline size_t hash_value(const FilePath& f) { 429 inline size_t hash_value(const FilePath& f) {
422 return hash_value(f.value()); 430 return hash_value(f.value());
423 } 431 }
424 432
425 #endif // COMPILER 433 #endif // COMPILER
426 434
427 } // namespace BASE_HASH_NAMESPACE 435 } // namespace BASE_HASH_NAMESPACE
428 436
429 #endif // BASE_FILE_PATH_H_ 437 #endif // BASE_FILE_PATH_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698