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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return path_ < that.path_; | 135 return path_ < that.path_; |
136 } | 136 } |
137 | 137 |
138 const StringType& value() const { return path_; } | 138 const StringType& value() const { return path_; } |
139 | 139 |
140 bool empty() const { return path_.empty(); } | 140 bool empty() const { return path_.empty(); } |
141 | 141 |
142 // Returns true if |character| is in kSeparators. | 142 // Returns true if |character| is in kSeparators. |
143 static bool IsSeparator(CharType character); | 143 static bool IsSeparator(CharType character); |
144 | 144 |
| 145 // Returns a vector of all of the components of the provided path. It is |
| 146 // equivalent to calling DirName().value() on the path's root component, |
| 147 // and BaseName().value() on each child component. |
| 148 void GetComponents(std::vector<FilePath::StringType>* components) const; |
| 149 |
| 150 // Returns true if this FilePath is a strict parent of the |child|. Absolute |
| 151 // and relative paths are accepted i.e. is /foo parent to /foo/bar and |
| 152 // is foo parent to foo/bar. Does not convert paths to absolute, follow |
| 153 // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own |
| 154 // parent. |
| 155 bool IsParent(const FilePath& child) const; |
| 156 |
145 // Returns a FilePath corresponding to the directory containing the path | 157 // Returns a FilePath corresponding to the directory containing the path |
146 // named by this object, stripping away the file component. If this object | 158 // named by this object, stripping away the file component. If this object |
147 // only contains one component, returns a FilePath identifying | 159 // only contains one component, returns a FilePath identifying |
148 // kCurrentDirectory. If this object already refers to the root directory, | 160 // kCurrentDirectory. If this object already refers to the root directory, |
149 // returns a FilePath identifying the root directory. | 161 // returns a FilePath identifying the root directory. |
150 FilePath DirName() const; | 162 FilePath DirName() const; |
151 | 163 |
152 // Returns a FilePath corresponding to the last path component of this | 164 // Returns a FilePath corresponding to the last path component of this |
153 // object, either a file or a directory. If this object already refers to | 165 // object, either a file or a directory. If this object already refers to |
154 // the root directory, returns a FilePath identifying the root directory; | 166 // the root directory, returns a FilePath identifying the root directory; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 namespace stdext { | 272 namespace stdext { |
261 | 273 |
262 inline size_t hash_value(const FilePath& f) { | 274 inline size_t hash_value(const FilePath& f) { |
263 return hash_value(f.value()); | 275 return hash_value(f.value()); |
264 } | 276 } |
265 | 277 |
266 } // namespace stdext | 278 } // namespace stdext |
267 #endif // COMPILER | 279 #endif // COMPILER |
268 | 280 |
269 #endif // BASE_FILE_PATH_H_ | 281 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |