OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // FilePath treats c://, c:\\, //, and \\ all equivalently. | 93 // FilePath treats c://, c:\\, //, and \\ all equivalently. |
94 // Reference: | 94 // Reference: |
95 // The Old New Thing, "Why is a drive letter permitted in front of UNC | 95 // The Old New Thing, "Why is a drive letter permitted in front of UNC |
96 // paths (sometimes)?", available at: | 96 // paths (sometimes)?", available at: |
97 // http://blogs.msdn.com/oldnewthing/archive/2005/11/22/495740.aspx | 97 // http://blogs.msdn.com/oldnewthing/archive/2005/11/22/495740.aspx |
98 | 98 |
99 #ifndef BASE_FILE_PATH_H_ | 99 #ifndef BASE_FILE_PATH_H_ |
100 #define BASE_FILE_PATH_H_ | 100 #define BASE_FILE_PATH_H_ |
101 #pragma once | 101 #pragma once |
102 | 102 |
| 103 #include <stddef.h> |
103 #include <string> | 104 #include <string> |
104 #include <vector> | 105 #include <vector> |
105 | 106 |
106 #include "base/base_api.h" | 107 #include "base/base_api.h" |
107 #include "base/basictypes.h" | |
108 #include "base/compiler_specific.h" | 108 #include "base/compiler_specific.h" |
109 #include "base/hash_tables.h" | 109 #include "base/hash_tables.h" |
| 110 #include "base/string16.h" |
110 #include "base/string_piece.h" // For implicit conversions. | 111 #include "base/string_piece.h" // For implicit conversions. |
| 112 #include "build/build_config.h" |
111 | 113 |
112 // Windows-style drive letter support and pathname separator characters can be | 114 // Windows-style drive letter support and pathname separator characters can be |
113 // enabled and disabled independently, to aid testing. These #defines are | 115 // enabled and disabled independently, to aid testing. These #defines are |
114 // here so that the same setting can be used in both the implementation and | 116 // here so that the same setting can be used in both the implementation and |
115 // in the unit test. | 117 // in the unit test. |
116 #if defined(OS_WIN) | 118 #if defined(OS_WIN) |
117 #define FILE_PATH_USES_DRIVE_LETTERS | 119 #define FILE_PATH_USES_DRIVE_LETTERS |
118 #define FILE_PATH_USES_WIN_SEPARATORS | 120 #define FILE_PATH_USES_WIN_SEPARATORS |
119 #endif // OS_WIN | 121 #endif // OS_WIN |
120 | 122 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 #define PRFilePathLiteral L"%ls" | 381 #define PRFilePathLiteral L"%ls" |
380 #endif // OS_WIN | 382 #endif // OS_WIN |
381 | 383 |
382 // Provide a hash function so that hash_sets and maps can contain FilePath | 384 // Provide a hash function so that hash_sets and maps can contain FilePath |
383 // objects. | 385 // objects. |
384 #if defined(COMPILER_GCC) | 386 #if defined(COMPILER_GCC) |
385 namespace __gnu_cxx { | 387 namespace __gnu_cxx { |
386 | 388 |
387 template<> | 389 template<> |
388 struct hash<FilePath> { | 390 struct hash<FilePath> { |
389 std::size_t operator()(const FilePath& f) const { | 391 size_t operator()(const FilePath& f) const { |
390 return hash<FilePath::StringType>()(f.value()); | 392 return hash<FilePath::StringType>()(f.value()); |
391 } | 393 } |
392 }; | 394 }; |
393 | 395 |
394 } // namespace __gnu_cxx | 396 } // namespace __gnu_cxx |
395 #elif defined(COMPILER_MSVC) | 397 #elif defined(COMPILER_MSVC) |
396 namespace stdext { | 398 namespace stdext { |
397 | 399 |
398 inline size_t hash_value(const FilePath& f) { | 400 inline size_t hash_value(const FilePath& f) { |
399 return hash_value(f.value()); | 401 return hash_value(f.value()); |
400 } | 402 } |
401 | 403 |
402 } // namespace stdext | 404 } // namespace stdext |
403 #endif // COMPILER | 405 #endif // COMPILER |
404 | 406 |
405 #endif // BASE_FILE_PATH_H_ | 407 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |