| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 // at all, making them safe to use without fear of blocking on I/O operations. | 46 // at all, making them safe to use without fear of blocking on I/O operations. |
| 47 // These methods do not function as mutators but instead return distinct | 47 // These methods do not function as mutators but instead return distinct |
| 48 // instances of FilePath objects, and are therefore safe to use on const | 48 // instances of FilePath objects, and are therefore safe to use on const |
| 49 // objects. The objects themselves are safe to share between threads. | 49 // objects. The objects themselves are safe to share between threads. |
| 50 // | 50 // |
| 51 // To aid in initialization of FilePath objects from string literals, a | 51 // To aid in initialization of FilePath objects from string literals, a |
| 52 // FILE_PATH_LITERAL macro is provided, which accounts for the difference | 52 // FILE_PATH_LITERAL macro is provided, which accounts for the difference |
| 53 // between char[]-based pathnames on POSIX systems and wchar_t[]-based | 53 // between char[]-based pathnames on POSIX systems and wchar_t[]-based |
| 54 // pathnames on Windows. | 54 // pathnames on Windows. |
| 55 // | 55 // |
| 56 // Paths can't contain NULs as a precaution agaist premature truncation. |
| 57 // |
| 56 // Because a FilePath object should not be instantiated at the global scope, | 58 // Because a FilePath object should not be instantiated at the global scope, |
| 57 // instead, use a FilePath::CharType[] and initialize it with | 59 // instead, use a FilePath::CharType[] and initialize it with |
| 58 // FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the | 60 // FILE_PATH_LITERAL. At runtime, a FilePath object can be created from the |
| 59 // character array. Example: | 61 // character array. Example: |
| 60 // | 62 // |
| 61 // | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt"); | 63 // | const FilePath::CharType kLogFileName[] = FILE_PATH_LITERAL("log.txt"); |
| 62 // | | 64 // | |
| 63 // | void Function() { | 65 // | void Function() { |
| 64 // | FilePath log_file_path(kLogFileName); | 66 // | FilePath log_file_path(kLogFileName); |
| 65 // | [...] | 67 // | [...] |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // Returns a FilePath object from a path name in UTF-8. This function | 338 // Returns a FilePath object from a path name in UTF-8. This function |
| 337 // should only be used for cases where you are sure that the input | 339 // should only be used for cases where you are sure that the input |
| 338 // string is UTF-8. | 340 // string is UTF-8. |
| 339 // | 341 // |
| 340 // Like AsUTF8Unsafe(), this function is unsafe. This function | 342 // Like AsUTF8Unsafe(), this function is unsafe. This function |
| 341 // internally calls SysWideToNativeMB() on POSIX systems other than Mac | 343 // internally calls SysWideToNativeMB() on POSIX systems other than Mac |
| 342 // and Chrome OS, to mitigate the encoding issue. See the comment at | 344 // and Chrome OS, to mitigate the encoding issue. See the comment at |
| 343 // AsUTF8Unsafe() for details. | 345 // AsUTF8Unsafe() for details. |
| 344 static FilePath FromUTF8Unsafe(const std::string& utf8); | 346 static FilePath FromUTF8Unsafe(const std::string& utf8); |
| 345 | 347 |
| 346 void WriteToPickle(Pickle* pickle); | 348 void WriteToPickle(Pickle* pickle) const; |
| 347 bool ReadFromPickle(PickleIterator* iter); | 349 bool ReadFromPickle(PickleIterator* iter); |
| 348 | 350 |
| 349 // Normalize all path separators to backslash on Windows | 351 // Normalize all path separators to backslash on Windows |
| 350 // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. | 352 // (if FILE_PATH_USES_WIN_SEPARATORS is true), or do nothing on POSIX systems. |
| 351 FilePath NormalizePathSeparators() const; | 353 FilePath NormalizePathSeparators() const; |
| 352 | 354 |
| 353 // Compare two strings in the same way the file system does. | 355 // Compare two strings in the same way the file system does. |
| 354 // Note that these always ignore case, even on file systems that are case- | 356 // Note that these always ignore case, even on file systems that are case- |
| 355 // sensitive. If case-sensitive comparison is ever needed, add corresponding | 357 // sensitive. If case-sensitive comparison is ever needed, add corresponding |
| 356 // methods here. | 358 // methods here. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 429 |
| 428 inline size_t hash_value(const FilePath& f) { | 430 inline size_t hash_value(const FilePath& f) { |
| 429 return hash_value(f.value()); | 431 return hash_value(f.value()); |
| 430 } | 432 } |
| 431 | 433 |
| 432 #endif // COMPILER | 434 #endif // COMPILER |
| 433 | 435 |
| 434 } // namespace BASE_HASH_NAMESPACE | 436 } // namespace BASE_HASH_NAMESPACE |
| 435 | 437 |
| 436 #endif // BASE_FILE_PATH_H_ | 438 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |