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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" | 190 // path == "C:\pics\jojo" suffix == " (1)", returns "C:\pics\jojo (1)" |
191 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" | 191 // path == "C:\pics.old\jojo" suffix == " (1)", returns "C:\pics.old\jojo (1)" |
192 FilePath InsertBeforeExtension(const StringType& suffix) const; | 192 FilePath InsertBeforeExtension(const StringType& suffix) const; |
193 | 193 |
194 // Replaces the extension of |file_name| with |extension|. If |file_name| | 194 // Replaces the extension of |file_name| with |extension|. If |file_name| |
195 // does not have an extension, them |extension| is added. If |extension| is | 195 // does not have an extension, them |extension| is added. If |extension| is |
196 // empty, then the extension is removed from |file_name|. | 196 // empty, then the extension is removed from |file_name|. |
197 // Returns "" if BaseName() == "." or "..". | 197 // Returns "" if BaseName() == "." or "..". |
198 FilePath ReplaceExtension(const StringType& extension) const; | 198 FilePath ReplaceExtension(const StringType& extension) const; |
199 | 199 |
| 200 // Returns true if the file path matches the specified extension. The test is |
| 201 // case insensitive. Don't forget the leading period if appropriate. |
| 202 bool MatchesExtension(const StringType& extension) const; |
| 203 |
200 // Returns a FilePath by appending a separator and the supplied path | 204 // Returns a FilePath by appending a separator and the supplied path |
201 // component to this object's path. Append takes care to avoid adding | 205 // component to this object's path. Append takes care to avoid adding |
202 // excessive separators if this object's path already ends with a separator. | 206 // excessive separators if this object's path already ends with a separator. |
203 // If this object's path is kCurrentDirectory, a new FilePath corresponding | 207 // If this object's path is kCurrentDirectory, a new FilePath corresponding |
204 // only to |component| is returned. |component| must be a relative path; | 208 // only to |component| is returned. |component| must be a relative path; |
205 // it is an error to pass an absolute path. | 209 // it is an error to pass an absolute path. |
206 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; | 210 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; |
207 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; | 211 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; |
208 | 212 |
209 // Although Windows StringType is std::wstring, since the encoding it uses for | 213 // Although Windows StringType is std::wstring, since the encoding it uses for |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 namespace stdext { | 276 namespace stdext { |
273 | 277 |
274 inline size_t hash_value(const FilePath& f) { | 278 inline size_t hash_value(const FilePath& f) { |
275 return hash_value(f.value()); | 279 return hash_value(f.value()); |
276 } | 280 } |
277 | 281 |
278 } // namespace stdext | 282 } // namespace stdext |
279 #endif // COMPILER | 283 #endif // COMPILER |
280 | 284 |
281 #endif // BASE_FILE_PATH_H_ | 285 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |