| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Windows-style drive letter support and pathname separator characters can be | 115 // Windows-style drive letter support and pathname separator characters can be |
| 116 // enabled and disabled independently, to aid testing. These #defines are | 116 // enabled and disabled independently, to aid testing. These #defines are |
| 117 // here so that the same setting can be used in both the implementation and | 117 // here so that the same setting can be used in both the implementation and |
| 118 // in the unit test. | 118 // in the unit test. |
| 119 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
| 120 #define FILE_PATH_USES_DRIVE_LETTERS | 120 #define FILE_PATH_USES_DRIVE_LETTERS |
| 121 #define FILE_PATH_USES_WIN_SEPARATORS | 121 #define FILE_PATH_USES_WIN_SEPARATORS |
| 122 #endif // OS_WIN | 122 #endif // OS_WIN |
| 123 | 123 |
| 124 class Pickle; | 124 class Pickle; |
| 125 class PickleIterator; |
| 125 | 126 |
| 126 // An abstraction to isolate users from the differences between native | 127 // An abstraction to isolate users from the differences between native |
| 127 // pathnames on different platforms. | 128 // pathnames on different platforms. |
| 128 class BASE_EXPORT FilePath { | 129 class BASE_EXPORT FilePath { |
| 129 public: | 130 public: |
| 130 #if defined(OS_POSIX) | 131 #if defined(OS_POSIX) |
| 131 // On most platforms, native pathnames are char arrays, and the encoding | 132 // On most platforms, native pathnames are char arrays, and the encoding |
| 132 // may or may not be specified. On Mac OS X, native pathnames are encoded | 133 // may or may not be specified. On Mac OS X, native pathnames are encoded |
| 133 // in UTF-8. | 134 // in UTF-8. |
| 134 typedef std::string StringType; | 135 typedef std::string StringType; |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // should only be used for cases where you are sure that the input | 333 // should only be used for cases where you are sure that the input |
| 333 // string is UTF-8. | 334 // string is UTF-8. |
| 334 // | 335 // |
| 335 // Like AsUTF8Unsafe(), this function is unsafe. This function | 336 // Like AsUTF8Unsafe(), this function is unsafe. This function |
| 336 // internally calls SysWideToNativeMB() on POSIX systems other than Mac | 337 // internally calls SysWideToNativeMB() on POSIX systems other than Mac |
| 337 // and Chrome OS, to mitigate the encoding issue. See the comment at | 338 // and Chrome OS, to mitigate the encoding issue. See the comment at |
| 338 // AsUTF8Unsafe() for details. | 339 // AsUTF8Unsafe() for details. |
| 339 static FilePath FromUTF8Unsafe(const std::string& utf8); | 340 static FilePath FromUTF8Unsafe(const std::string& utf8); |
| 340 | 341 |
| 341 void WriteToPickle(Pickle* pickle); | 342 void WriteToPickle(Pickle* pickle); |
| 342 bool ReadFromPickle(Pickle* pickle, void** iter); | 343 bool ReadFromPickle(PickleIterator* iter); |
| 343 | 344 |
| 344 // Normalize all path separators to backslash on Windows | 345 // Normalize all path separators to backslash on Windows |
| 345 // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. | 346 // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. |
| 346 FilePath NormalizePathSeparators() const; | 347 FilePath NormalizePathSeparators() const; |
| 347 | 348 |
| 348 // Compare two strings in the same way the file system does. | 349 // Compare two strings in the same way the file system does. |
| 349 // Note that these always ignore case, even on file systems that are case- | 350 // Note that these always ignore case, even on file systems that are case- |
| 350 // sensitive. If case-sensitive comparison is ever needed, add corresponding | 351 // sensitive. If case-sensitive comparison is ever needed, add corresponding |
| 351 // methods here. | 352 // methods here. |
| 352 // The methods are written as a static method so that they can also be used | 353 // The methods are written as a static method so that they can also be used |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 420 |
| 420 inline size_t hash_value(const FilePath& f) { | 421 inline size_t hash_value(const FilePath& f) { |
| 421 return hash_value(f.value()); | 422 return hash_value(f.value()); |
| 422 } | 423 } |
| 423 | 424 |
| 424 #endif // COMPILER | 425 #endif // COMPILER |
| 425 | 426 |
| 426 } // namespace BASE_HASH_NAMESPACE | 427 } // namespace BASE_HASH_NAMESPACE |
| 427 | 428 |
| 428 #endif // BASE_FILE_PATH_H_ | 429 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |