| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // Remove trailing separators from this object. If the path is absolute, it | 348 // Remove trailing separators from this object. If the path is absolute, it |
| 349 // will never be stripped any more than to refer to the absolute root | 349 // will never be stripped any more than to refer to the absolute root |
| 350 // directory, so "////" will become "/", not "". A leading pair of | 350 // directory, so "////" will become "/", not "". A leading pair of |
| 351 // separators is never stripped, to support alternate roots. This is used to | 351 // separators is never stripped, to support alternate roots. This is used to |
| 352 // support UNC paths on Windows. | 352 // support UNC paths on Windows. |
| 353 void StripTrailingSeparatorsInternal(); | 353 void StripTrailingSeparatorsInternal(); |
| 354 | 354 |
| 355 StringType path_; | 355 StringType path_; |
| 356 }; | 356 }; |
| 357 | 357 |
| 358 // Macros for string literal initialization of FilePath::CharType[]. | 358 // Macros for string literal initialization of FilePath::CharType[], and for |
| 359 // using a FilePath::CharType[] in a printf-style format string. |
| 359 #if defined(OS_POSIX) | 360 #if defined(OS_POSIX) |
| 360 #define FILE_PATH_LITERAL(x) x | 361 #define FILE_PATH_LITERAL(x) x |
| 362 #define PRFilePath "s" |
| 361 #elif defined(OS_WIN) | 363 #elif defined(OS_WIN) |
| 362 #define FILE_PATH_LITERAL(x) L ## x | 364 #define FILE_PATH_LITERAL(x) L ## x |
| 365 #define PRFilePath "ls" |
| 363 #endif // OS_WIN | 366 #endif // OS_WIN |
| 364 | 367 |
| 365 // Provide a hash function so that hash_sets and maps can contain FilePath | 368 // Provide a hash function so that hash_sets and maps can contain FilePath |
| 366 // objects. | 369 // objects. |
| 367 #if defined(COMPILER_GCC) | 370 #if defined(COMPILER_GCC) |
| 368 namespace __gnu_cxx { | 371 namespace __gnu_cxx { |
| 369 | 372 |
| 370 template<> | 373 template<> |
| 371 struct hash<FilePath> { | 374 struct hash<FilePath> { |
| 372 std::size_t operator()(const FilePath& f) const { | 375 std::size_t operator()(const FilePath& f) const { |
| 373 return hash<FilePath::StringType>()(f.value()); | 376 return hash<FilePath::StringType>()(f.value()); |
| 374 } | 377 } |
| 375 }; | 378 }; |
| 376 | 379 |
| 377 } // namespace __gnu_cxx | 380 } // namespace __gnu_cxx |
| 378 #elif defined(COMPILER_MSVC) | 381 #elif defined(COMPILER_MSVC) |
| 379 namespace stdext { | 382 namespace stdext { |
| 380 | 383 |
| 381 inline size_t hash_value(const FilePath& f) { | 384 inline size_t hash_value(const FilePath& f) { |
| 382 return hash_value(f.value()); | 385 return hash_value(f.value()); |
| 383 } | 386 } |
| 384 | 387 |
| 385 } // namespace stdext | 388 } // namespace stdext |
| 386 #endif // COMPILER | 389 #endif // COMPILER |
| 387 | 390 |
| 388 #endif // BASE_FILE_PATH_H_ | 391 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |