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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 bool empty() const { return path_.empty(); } | 171 bool empty() const { return path_.empty(); } |
172 | 172 |
173 // Returns true if |character| is in kSeparators. | 173 // Returns true if |character| is in kSeparators. |
174 static bool IsSeparator(CharType character); | 174 static bool IsSeparator(CharType character); |
175 | 175 |
176 // Returns a vector of all of the components of the provided path. It is | 176 // Returns a vector of all of the components of the provided path. It is |
177 // equivalent to calling DirName().value() on the path's root component, | 177 // equivalent to calling DirName().value() on the path's root component, |
178 // and BaseName().value() on each child component. | 178 // and BaseName().value() on each child component. |
179 void GetComponents(std::vector<FilePath::StringType>* components) const; | 179 void GetComponents(std::vector<FilePath::StringType>* components) const; |
180 | 180 |
| 181 // Returns true, and sets *path to resulting full path, if relative_path can |
| 182 // be applied to current path by resolving any '..' it may contain. Returns |
| 183 // false otherwise, e.g., if relative path is absolute, or if it climbs back |
| 184 // up the hierarchy too far (i.e., beyond the root of current path). |
| 185 // |
| 186 // Note that if the current path ends with a file name, we won't try to |
| 187 // figure it out (so this method doesn't go to the disk) and we will blindly |
| 188 // append relative_path at the end of the current path, including the file |
| 189 // name in the current path (if any). |
| 190 bool AppendAndResolveRelative(const FilePath& relative_path, |
| 191 FilePath* path) const; |
| 192 |
181 // Returns true if this FilePath is a strict parent of the |child|. Absolute | 193 // Returns true if this FilePath is a strict parent of the |child|. Absolute |
182 // and relative paths are accepted i.e. is /foo parent to /foo/bar and | 194 // and relative paths are accepted i.e. is /foo parent to /foo/bar and |
183 // is foo parent to foo/bar. Does not convert paths to absolute, follow | 195 // is foo parent to foo/bar. Does not convert paths to absolute, follow |
184 // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own | 196 // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own |
185 // parent. | 197 // parent. |
186 bool IsParent(const FilePath& child) const; | 198 bool IsParent(const FilePath& child) const; |
187 | 199 |
188 // If IsParent(child) holds, appends to path (if non-NULL) the | 200 // If IsParent(child) holds, appends to path (if non-NULL) the |
189 // relative path to child and returns true. For example, if parent | 201 // relative path to child and returns true. For example, if parent |
190 // holds "/Users/johndoe/Library/Application Support", child holds | 202 // holds "/Users/johndoe/Library/Application Support", child holds |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 namespace stdext { | 336 namespace stdext { |
325 | 337 |
326 inline size_t hash_value(const FilePath& f) { | 338 inline size_t hash_value(const FilePath& f) { |
327 return hash_value(f.value()); | 339 return hash_value(f.value()); |
328 } | 340 } |
329 | 341 |
330 } // namespace stdext | 342 } // namespace stdext |
331 #endif // COMPILER | 343 #endif // COMPILER |
332 | 344 |
333 #endif // BASE_FILE_PATH_H_ | 345 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |