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

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: Simplified special case checking 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') | base/file_path.cc » ('J')
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(
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
252 // Returns true if the file path matches the specified extension. The test is 257 // Returns true if the file path matches the specified extension. The test is
253 // case insensitive. Don't forget the leading period if appropriate. 258 // case insensitive. Don't forget the leading period if appropriate.
254 bool MatchesExtension(const StringType& extension) const; 259 bool MatchesExtension(const StringType& extension) const;
255 260
256 // Returns a FilePath by appending a separator and the supplied path 261 // Returns a FilePath by appending a separator and the supplied path
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 425
421 inline size_t hash_value(const FilePath& f) { 426 inline size_t hash_value(const FilePath& f) {
422 return hash_value(f.value()); 427 return hash_value(f.value());
423 } 428 }
424 429
425 #endif // COMPILER 430 #endif // COMPILER
426 431
427 } // namespace BASE_HASH_NAMESPACE 432 } // namespace BASE_HASH_NAMESPACE
428 433
429 #endif // BASE_FILE_PATH_H_ 434 #endif // BASE_FILE_PATH_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_path.cc » ('j') | base/file_path.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698