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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 // Returns a FilePath by appending a separator and the supplied path | 183 // Returns a FilePath by appending a separator and the supplied path |
184 // component to this object's path. Append takes care to avoid adding | 184 // component to this object's path. Append takes care to avoid adding |
185 // excessive separators if this object's path already ends with a separator. | 185 // excessive separators if this object's path already ends with a separator. |
186 // If this object's path is kCurrentDirectory, a new FilePath corresponding | 186 // If this object's path is kCurrentDirectory, a new FilePath corresponding |
187 // only to |component| is returned. |component| must be a relative path; | 187 // only to |component| is returned. |component| must be a relative path; |
188 // it is an error to pass an absolute path. | 188 // it is an error to pass an absolute path. |
189 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; | 189 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; |
190 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; | 190 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; |
191 | 191 |
| 192 // Although Windows StringType is std::wstring, since the encoding it uses for |
| 193 // paths is well defined, it can handle ASCII path components as well. |
| 194 // Mac uses UTF8, and since ASCII is a subset of that, it works there as well. |
| 195 // On Linux, although it can use any 8-bit encoding for paths, we assume that |
| 196 // ASCII is a valid subset, regardless of the encoding, since many operating |
| 197 // system paths will always be ASCII. |
| 198 FilePath AppendASCII(const std::string& component) const WARN_UNUSED_RESULT; |
| 199 |
192 // Returns true if this FilePath contains an absolute path. On Windows, an | 200 // Returns true if this FilePath contains an absolute path. On Windows, an |
193 // absolute path begins with either a drive letter specification followed by | 201 // absolute path begins with either a drive letter specification followed by |
194 // a separator character, or with two separator characters. On POSIX | 202 // a separator character, or with two separator characters. On POSIX |
195 // platforms, an absolute path begins with a separator character. | 203 // platforms, an absolute path begins with a separator character. |
196 bool IsAbsolute() const; | 204 bool IsAbsolute() const; |
197 | 205 |
198 // Returns a copy of this FilePath that does not end with a trailing | 206 // Returns a copy of this FilePath that does not end with a trailing |
199 // separator. | 207 // separator. |
200 FilePath StripTrailingSeparators() const; | 208 FilePath StripTrailingSeparators() const; |
201 | 209 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 namespace stdext { | 255 namespace stdext { |
248 | 256 |
249 inline size_t hash_value(const FilePath& f) { | 257 inline size_t hash_value(const FilePath& f) { |
250 return hash_value(f.value()); | 258 return hash_value(f.value()); |
251 } | 259 } |
252 | 260 |
253 } // namespace stdext | 261 } // namespace stdext |
254 #endif // COMPILER | 262 #endif // COMPILER |
255 | 263 |
256 #endif // BASE_FILE_PATH_H_ | 264 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |