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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // | void Function() { | 60 // | void Function() { |
61 // | FilePath log_file_path(kLogFileName); | 61 // | FilePath log_file_path(kLogFileName); |
62 // | [...] | 62 // | [...] |
63 // | } | 63 // | } |
64 | 64 |
65 #ifndef BASE_FILE_PATH_H_ | 65 #ifndef BASE_FILE_PATH_H_ |
66 #define BASE_FILE_PATH_H_ | 66 #define BASE_FILE_PATH_H_ |
67 | 67 |
68 #include <string> | 68 #include <string> |
69 | 69 |
| 70 #include "base/compiler_specific.h" |
70 #include "base/basictypes.h" | 71 #include "base/basictypes.h" |
71 | 72 |
72 // Windows-style drive letter support and pathname separator characters can be | 73 // Windows-style drive letter support and pathname separator characters can be |
73 // enabled and disabled independently, to aid testing. These #defines are | 74 // enabled and disabled independently, to aid testing. These #defines are |
74 // here so that the same setting can be used in both the implementation and | 75 // here so that the same setting can be used in both the implementation and |
75 // in the unit test. | 76 // in the unit test. |
76 #if defined(OS_WIN) | 77 #if defined(OS_WIN) |
77 #define FILE_PATH_USES_DRIVE_LETTERS | 78 #define FILE_PATH_USES_DRIVE_LETTERS |
78 #define FILE_PATH_USES_WIN_SEPARATORS | 79 #define FILE_PATH_USES_WIN_SEPARATORS |
79 #endif // OS_WIN | 80 #endif // OS_WIN |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // the root directory, returns a FilePath identifying the root directory; | 135 // the root directory, returns a FilePath identifying the root directory; |
135 // this is the only situation in which BaseName will return an absolute path. | 136 // this is the only situation in which BaseName will return an absolute path. |
136 FilePath BaseName() const; | 137 FilePath BaseName() const; |
137 | 138 |
138 // Returns a FilePath by appending a separator and the supplied path | 139 // Returns a FilePath by appending a separator and the supplied path |
139 // component to this object's path. Append takes care to avoid adding | 140 // component to this object's path. Append takes care to avoid adding |
140 // excessive separators if this object's path already ends with a separator. | 141 // excessive separators if this object's path already ends with a separator. |
141 // If this object's path is kCurrentDirectory, a new FilePath corresponding | 142 // If this object's path is kCurrentDirectory, a new FilePath corresponding |
142 // only to |component| is returned. |component| must be a relative path; | 143 // only to |component| is returned. |component| must be a relative path; |
143 // it is an error to pass an absolute path. | 144 // it is an error to pass an absolute path. |
144 FilePath Append(const StringType& component) const; | 145 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; |
145 | 146 |
146 // Returns true if this FilePath contains an absolute path. On Windows, an | 147 // Returns true if this FilePath contains an absolute path. On Windows, an |
147 // absolute path begins with either a drive letter specification followed by | 148 // absolute path begins with either a drive letter specification followed by |
148 // a separator character, or with two separator characters. On POSIX | 149 // a separator character, or with two separator characters. On POSIX |
149 // platforms, an absolute path begins with a separator character. | 150 // platforms, an absolute path begins with a separator character. |
150 bool IsAbsolute() const; | 151 bool IsAbsolute() const; |
151 | 152 |
152 // Older Chromium code assumes that paths are always wstrings. | 153 // Older Chromium code assumes that paths are always wstrings. |
153 // This function converts a wstring to a FilePath, and is useful to smooth | 154 // This function converts a wstring to a FilePath, and is useful to smooth |
154 // porting that old code to the FilePath API. | 155 // porting that old code to the FilePath API. |
(...skipping 27 matching lines...) Expand all Loading... |
182 }; | 183 }; |
183 | 184 |
184 // Macros for string literal initialization of FilePath::CharType[]. | 185 // Macros for string literal initialization of FilePath::CharType[]. |
185 #if defined(OS_POSIX) | 186 #if defined(OS_POSIX) |
186 #define FILE_PATH_LITERAL(x) x | 187 #define FILE_PATH_LITERAL(x) x |
187 #elif defined(OS_WIN) | 188 #elif defined(OS_WIN) |
188 #define FILE_PATH_LITERAL(x) L ## x | 189 #define FILE_PATH_LITERAL(x) L ## x |
189 #endif // OS_WIN | 190 #endif // OS_WIN |
190 | 191 |
191 #endif // BASE_FILE_PATH_H_ | 192 #endif // BASE_FILE_PATH_H_ |
OLD | NEW |