| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return path_ == that.path_; | 125 return path_ == that.path_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 // Required for some STL containers and operations | 128 // Required for some STL containers and operations |
| 129 bool operator<(const FilePath& that) const { | 129 bool operator<(const FilePath& that) const { |
| 130 return path_ < that.path_; | 130 return path_ < that.path_; |
| 131 } | 131 } |
| 132 | 132 |
| 133 const StringType& value() const { return path_; } | 133 const StringType& value() const { return path_; } |
| 134 | 134 |
| 135 bool empty() const { return path_.empty(); } | |
| 136 | |
| 137 // Returns true if |character| is in kSeparators. | 135 // Returns true if |character| is in kSeparators. |
| 138 static bool IsSeparator(CharType character); | 136 static bool IsSeparator(CharType character); |
| 139 | 137 |
| 140 // Returns a FilePath corresponding to the directory containing the path | 138 // Returns a FilePath corresponding to the directory containing the path |
| 141 // named by this object, stripping away the file component. If this object | 139 // named by this object, stripping away the file component. If this object |
| 142 // only contains one component, returns a FilePath identifying | 140 // only contains one component, returns a FilePath identifying |
| 143 // kCurrentDirectory. If this object already refers to the root directory, | 141 // kCurrentDirectory. If this object already refers to the root directory, |
| 144 // returns a FilePath identifying the root directory. | 142 // returns a FilePath identifying the root directory. |
| 145 FilePath DirName() const; | 143 FilePath DirName() const; |
| 146 | 144 |
| 147 // Returns a FilePath corresponding to the last path component of this | 145 // Returns a FilePath corresponding to the last path component of this |
| 148 // object, either a file or a directory. If this object already refers to | 146 // object, either a file or a directory. If this object already refers to |
| 149 // the root directory, returns a FilePath identifying the root directory; | 147 // the root directory, returns a FilePath identifying the root directory; |
| 150 // this is the only situation in which BaseName will return an absolute path. | 148 // this is the only situation in which BaseName will return an absolute path. |
| 151 FilePath BaseName() const; | 149 StringType BaseName() const; |
| 152 | 150 |
| 153 // Returns a FilePath by appending a separator and the supplied path | 151 // Returns a FilePath by appending a separator and the supplied path |
| 154 // component to this object's path. Append takes care to avoid adding | 152 // component to this object's path. Append takes care to avoid adding |
| 155 // excessive separators if this object's path already ends with a separator. | 153 // excessive separators if this object's path already ends with a separator. |
| 156 // If this object's path is kCurrentDirectory, a new FilePath corresponding | 154 // If this object's path is kCurrentDirectory, a new FilePath corresponding |
| 157 // only to |component| is returned. |component| must be a relative path; | 155 // only to |component| is returned. |component| must be a relative path; |
| 158 // it is an error to pass an absolute path. | 156 // it is an error to pass an absolute path. |
| 159 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; | 157 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; |
| 160 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; | 158 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; |
| 161 | 159 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 struct hash<FilePath> { | 212 struct hash<FilePath> { |
| 215 size_t operator()(const FilePath& f) const { | 213 size_t operator()(const FilePath& f) const { |
| 216 return std::tr1::hash<FilePath::StringType>()(f.value()); | 214 return std::tr1::hash<FilePath::StringType>()(f.value()); |
| 217 } | 215 } |
| 218 }; | 216 }; |
| 219 | 217 |
| 220 } // namespace __gnu_cxx | 218 } // namespace __gnu_cxx |
| 221 #endif // defined(COMPILER_GCC) | 219 #endif // defined(COMPILER_GCC) |
| 222 | 220 |
| 223 #endif // BASE_FILE_PATH_H_ | 221 #endif // BASE_FILE_PATH_H_ |
| OLD | NEW |