OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 return path_ == that.path_; | 125 return path_ == that.path_; |
126 } | 126 } |
127 | 127 |
128 // Required for some STL containers and operations | 128 // Required for some STL containers and operations |
129 bool operator<(const FilePath& that) const { | 129 bool operator<(const FilePath& that) const { |
130 return path_ < that.path_; | 130 return path_ < that.path_; |
131 } | 131 } |
132 | 132 |
133 const StringType& value() const { return path_; } | 133 const StringType& value() const { return path_; } |
134 | 134 |
135 // Returns value() encoded as a UTF8 std::string. Be careful to not use this | |
136 // in places that use filesystem APIs as it won't be portable. | |
137 const std::string UTF8Value() const; | |
138 | |
139 // Returns true if |character| is in kSeparators. | 135 // Returns true if |character| is in kSeparators. |
140 static bool IsSeparator(CharType character); | 136 static bool IsSeparator(CharType character); |
141 | 137 |
142 // Returns a FilePath corresponding to the directory containing the path | 138 // Returns a FilePath corresponding to the directory containing the path |
143 // named by this object, stripping away the file component. If this object | 139 // named by this object, stripping away the file component. If this object |
144 // only contains one component, returns a FilePath identifying | 140 // only contains one component, returns a FilePath identifying |
145 // kCurrentDirectory. If this object already refers to the root directory, | 141 // kCurrentDirectory. If this object already refers to the root directory, |
146 // returns a FilePath identifying the root directory. | 142 // returns a FilePath identifying the root directory. |
147 FilePath DirName() const; | 143 FilePath DirName() const; |
148 | 144 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 struct hash<FilePath> { | 212 struct hash<FilePath> { |
217 size_t operator()(const FilePath& f) const { | 213 size_t operator()(const FilePath& f) const { |
218 return std::tr1::hash<FilePath::StringType>()(f.value()); | 214 return std::tr1::hash<FilePath::StringType>()(f.value()); |
219 } | 215 } |
220 }; | 216 }; |
221 | 217 |
222 } // namespace __gnu_cxx | 218 } // namespace __gnu_cxx |
223 #endif // defined(COMPILER_GCC) | 219 #endif // defined(COMPILER_GCC) |
224 | 220 |
225 #endif // BASE_FILE_PATH_H_ | 221 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |