| OLD | NEW |
| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Returns ".jpg" for path "C:\pics\jojo.jpg", or an empty string if | 231 // Returns ".jpg" for path "C:\pics\jojo.jpg", or an empty string if |
| 232 // the file has no extension. If non-empty, Extension() will always start | 232 // the file has no extension. If non-empty, Extension() will always start |
| 233 // with precisely one ".". The following code should always work regardless | 233 // with precisely one ".". The following code should always work regardless |
| 234 // of the value of path. For common double-extensions like .tar.gz and | 234 // of the value of path. For common double-extensions like .tar.gz and |
| 235 // .user.js, this method returns the combined extension. For a single | 235 // .user.js, this method returns the combined extension. For a single |
| 236 // component, use FinalExtension(). | 236 // component, use FinalExtension(). |
| 237 // new_path = path.RemoveExtension().value().append(path.Extension()); | 237 // new_path = path.RemoveExtension().value().append(path.Extension()); |
| 238 // ASSERT(new_path == path.value()); | 238 // ASSERT(new_path == path.value()); |
| 239 // NOTE: this is different from the original file_util implementation which | 239 // NOTE: this is different from the original file_util implementation which |
| 240 // returned the extension without a leading "." ("jpg" instead of ".jpg") | 240 // returned the extension without a leading "." ("jpg" instead of ".jpg") |
| 241 StringType Extension() const; | 241 StringType Extension() const WARN_UNUSED_RESULT; |
| 242 | 242 |
| 243 // Returns the path's file extension, as in Extension(), but will | 243 // Returns the path's file extension, as in Extension(), but will |
| 244 // never return a double extension. | 244 // never return a double extension. |
| 245 // | 245 // |
| 246 // TODO(davidben): Check all our extension-sensitive code to see if | 246 // TODO(davidben): Check all our extension-sensitive code to see if |
| 247 // we can rename this to Extension() and the other to something like | 247 // we can rename this to Extension() and the other to something like |
| 248 // LongExtension(), defaulting to short extensions and leaving the | 248 // LongExtension(), defaulting to short extensions and leaving the |
| 249 // long "extensions" to logic like base::GetUniquePathNumber(). | 249 // long "extensions" to logic like base::GetUniquePathNumber(). |
| 250 StringType FinalExtension() const; | 250 StringType FinalExtension() const WARN_UNUSED_RESULT; |
| 251 | 251 |
| 252 // Returns "C:\pics\jojo" for path "C:\pics\jojo.jpg" | 252 // Returns "C:\pics\jojo" for path "C:\pics\jojo.jpg" |
| 253 // NOTE: this is slightly different from the similar file_util implementation | 253 // NOTE: this is slightly different from the similar file_util implementation |
| 254 // which returned simply 'jojo'. | 254 // which returned simply 'jojo'. |
| 255 FilePath RemoveExtension() const WARN_UNUSED_RESULT; | 255 FilePath RemoveExtension() const WARN_UNUSED_RESULT; |
| 256 | 256 |
| 257 // Removes the path's file extension, as in RemoveExtension(), but | 257 // Removes the path's file extension, as in RemoveExtension(), but |
| 258 // ignores double extensions. | 258 // ignores double extensions. |
| 259 FilePath RemoveFinalExtension() const WARN_UNUSED_RESULT; | 259 FilePath RemoveFinalExtension() const WARN_UNUSED_RESULT; |
| 260 | 260 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 template<> | 457 template<> |
| 458 struct hash<base::FilePath> { | 458 struct hash<base::FilePath> { |
| 459 size_t operator()(const base::FilePath& f) const { | 459 size_t operator()(const base::FilePath& f) const { |
| 460 return hash<base::FilePath::StringType>()(f.value()); | 460 return hash<base::FilePath::StringType>()(f.value()); |
| 461 } | 461 } |
| 462 }; | 462 }; |
| 463 | 463 |
| 464 } // namespace BASE_HASH_NAMESPACE | 464 } // namespace BASE_HASH_NAMESPACE |
| 465 | 465 |
| 466 #endif // BASE_FILES_FILE_PATH_H_ | 466 #endif // BASE_FILES_FILE_PATH_H_ |
| OLD | NEW |