Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Side by Side Diff: base/file_path.h

Issue 8825: Begin the first small step towards using FilePath everywhere: (Closed)
Patch Set: works on windows Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/base_paths_linux.cc ('k') | base/file_path.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // only to |component| is returned. |component| must be a relative path; 138 // only to |component| is returned. |component| must be a relative path;
139 // it is an error to pass an absolute path. 139 // it is an error to pass an absolute path.
140 FilePath Append(const StringType& component) const; 140 FilePath Append(const StringType& component) const;
141 141
142 // Returns true if this FilePath contains an absolute path. On Windows, an 142 // Returns true if this FilePath contains an absolute path. On Windows, an
143 // absolute path begins with either a drive letter specification followed by 143 // absolute path begins with either a drive letter specification followed by
144 // a separator character, or with two separator characters. On POSIX 144 // a separator character, or with two separator characters. On POSIX
145 // platforms, an absolute path begins with a separator character. 145 // platforms, an absolute path begins with a separator character.
146 bool IsAbsolute() const; 146 bool IsAbsolute() const;
147 147
148 // Older Chromium code assumes that paths are always wstrings.
149 // This function converts a wstring to a FilePath, and is useful to smooth
150 // porting that old code to the FilePath API.
151 // It has "Hack" in its name so people feel bad about using it.
152 // TODO(port): remove these functions.
153 static FilePath FromWStringHack(const std::wstring& wstring);
154
155 // Older Chromium code assumes that paths are always wstrings.
156 // This function produces a wstring from a FilePath, and is useful to smooth
157 // porting that old code to the FilePath API.
158 // It has "Hack" in its name so people feel bad about using it.
159 // TODO(port): remove these functions.
160 std::wstring ToWStringHack() const;
161
148 private: 162 private:
149 // If this FilePath contains a drive letter specification, returns the 163 // If this FilePath contains a drive letter specification, returns the
150 // position of the last character of the drive letter specification, 164 // position of the last character of the drive letter specification,
151 // otherwise returns npos. This can only be true on Windows, when a pathname 165 // otherwise returns npos. This can only be true on Windows, when a pathname
152 // begins with a letter followed by a colon. On other platforms, this always 166 // begins with a letter followed by a colon. On other platforms, this always
153 // returns npos. 167 // returns npos.
154 StringType::size_type FindDriveLetter() const; 168 StringType::size_type FindDriveLetter() const;
155 169
156 // Remove trailing separators from this object. If the path is absolute, it 170 // Remove trailing separators from this object. If the path is absolute, it
157 // will never be stripped any more than to refer to the absolute root 171 // will never be stripped any more than to refer to the absolute root
158 // directory, so "////" will become "/", not "". A leading pair of 172 // directory, so "////" will become "/", not "". A leading pair of
159 // separators is never stripped, to support alternate roots. This is used to 173 // separators is never stripped, to support alternate roots. This is used to
160 // support UNC paths on Windows. 174 // support UNC paths on Windows.
161 void StripTrailingSeparators(); 175 void StripTrailingSeparators();
162 176
163 StringType path_; 177 StringType path_;
164 }; 178 };
165 179
166 // Macros for string literal initialization of FilePath::CharType[]. 180 // Macros for string literal initialization of FilePath::CharType[].
167 #if defined(OS_POSIX) 181 #if defined(OS_POSIX)
168 #define FILE_PATH_LITERAL(x) x 182 #define FILE_PATH_LITERAL(x) x
169 #elif defined(OS_WIN) 183 #elif defined(OS_WIN)
170 #define FILE_PATH_LITERAL(x) L ## x 184 #define FILE_PATH_LITERAL(x) L ## x
171 #endif // OS_WIN 185 #endif // OS_WIN
172 186
173 #endif // BASE_FILE_PATH_H_ 187 #endif // BASE_FILE_PATH_H_
OLDNEW
« no previous file with comments | « base/base_paths_linux.cc ('k') | base/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698