Chromium Code Reviews| 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 // Note that if the current path ends with a file name, we won't try to | |
|
brettw
2009/10/20 06:06:19
Can you put a blank line separating these two para
MAD
2009/10/20 13:43:29
Done.
| |
| 186 // figure it out (so this method doesn't go to the disk) and we will blindly | |
| 187 // append relative_path at the end of the current path, including the file | |
| 188 // name in the current path (if any). | |
| 189 bool AppendAndResolveRelative(const FilePath& relative_path, | |
| 190 FilePath* path) const; | |
| 191 | |
| 181 // Returns true if this FilePath is a strict parent of the |child|. Absolute | 192 // 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 | 193 // 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 | 194 // 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 | 195 // symlinks or directory navigation (e.g. ".."). A path is *NOT* its own |
| 185 // parent. | 196 // parent. |
| 186 bool IsParent(const FilePath& child) const; | 197 bool IsParent(const FilePath& child) const; |
| 187 | 198 |
| 188 // If IsParent(child) holds, appends to path (if non-NULL) the | 199 // If IsParent(child) holds, appends to path (if non-NULL) the |
| 189 // relative path to child and returns true. For example, if parent | 200 // relative path to child and returns true. For example, if parent |
| 190 // holds "/Users/johndoe/Library/Application Support", child holds | 201 // holds "/Users/johndoe/Library/Application Support", child holds |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 namespace stdext { | 335 namespace stdext { |
| 325 | 336 |
| 326 inline size_t hash_value(const FilePath& f) { | 337 inline size_t hash_value(const FilePath& f) { |
| 327 return hash_value(f.value()); | 338 return hash_value(f.value()); |
| 328 } | 339 } |
| 329 | 340 |
| 330 } // namespace stdext | 341 } // namespace stdext |
| 331 #endif // COMPILER | 342 #endif // COMPILER |
| 332 | 343 |
| 333 #endif // BASE_FILE_PATH_H_ | 344 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |