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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Returns true if this FilePath contains an absolute path. On Windows, an | 192 // Returns true if this FilePath contains an absolute path. On Windows, an |
193 // absolute path begins with either a drive letter specification followed by | 193 // absolute path begins with either a drive letter specification followed by |
194 // a separator character, or with two separator characters. On POSIX | 194 // a separator character, or with two separator characters. On POSIX |
195 // platforms, an absolute path begins with a separator character. | 195 // platforms, an absolute path begins with a separator character. |
196 bool IsAbsolute() const; | 196 bool IsAbsolute() const; |
197 | 197 |
198 // Returns true if this FilePath represents a parent dir of |other|. Both | |
199 // paths are normalized before doing the comparison, but neither |this| nor | |
200 // |other| are modified. | |
201 bool Contains(const FilePath& other) const; | |
202 | |
203 // Returns a copy of this FilePath that does not end with a trailing | 198 // Returns a copy of this FilePath that does not end with a trailing |
204 // separator. | 199 // separator. |
205 FilePath StripTrailingSeparators() const; | 200 FilePath StripTrailingSeparators() const; |
206 | 201 |
207 // Older Chromium code assumes that paths are always wstrings. | 202 // Older Chromium code assumes that paths are always wstrings. |
208 // This function converts a wstring to a FilePath, and is useful to smooth | 203 // This function converts a wstring to a FilePath, and is useful to smooth |
209 // porting that old code to the FilePath API. | 204 // porting that old code to the FilePath API. |
210 // It has "Hack" in its name so people feel bad about using it. | 205 // It has "Hack" in its name so people feel bad about using it. |
211 // TODO(port): remove these functions. | 206 // TODO(port): remove these functions. |
212 static FilePath FromWStringHack(const std::wstring& wstring); | 207 static FilePath FromWStringHack(const std::wstring& wstring); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 namespace stdext { | 247 namespace stdext { |
253 | 248 |
254 inline size_t hash_value(const FilePath& f) { | 249 inline size_t hash_value(const FilePath& f) { |
255 return hash_value(f.value()); | 250 return hash_value(f.value()); |
256 } | 251 } |
257 | 252 |
258 } // namespace stdext | 253 } // namespace stdext |
259 #endif // COMPILER | 254 #endif // COMPILER |
260 | 255 |
261 #endif // BASE_FILE_PATH_H_ | 256 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |