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

Side by Side Diff: base/file_path.h

Issue 113996: Move a few functions commonly called with char* to StringPiece. (Closed)
Patch Set: Created 11 years, 6 months 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 | « no previous file | 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/basictypes.h" 70 #include "base/basictypes.h"
71 #include "base/compiler_specific.h" 71 #include "base/compiler_specific.h"
72 #include "base/hash_tables.h" 72 #include "base/hash_tables.h"
73 #include "base/string_piece.h" // For implicit conversions.
Mark Mentovai 2009/05/29 13:04:55 I don't think comments like this for #includes are
73 74
74 // Windows-style drive letter support and pathname separator characters can be 75 // Windows-style drive letter support and pathname separator characters can be
75 // enabled and disabled independently, to aid testing. These #defines are 76 // enabled and disabled independently, to aid testing. These #defines are
76 // here so that the same setting can be used in both the implementation and 77 // here so that the same setting can be used in both the implementation and
77 // in the unit test. 78 // in the unit test.
78 #if defined(OS_WIN) 79 #if defined(OS_WIN)
79 #define FILE_PATH_USES_DRIVE_LETTERS 80 #define FILE_PATH_USES_DRIVE_LETTERS
80 #define FILE_PATH_USES_WIN_SEPARATORS 81 #define FILE_PATH_USES_WIN_SEPARATORS
81 #endif // OS_WIN 82 #endif // OS_WIN
82 83
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // it is an error to pass an absolute path. 193 // it is an error to pass an absolute path.
193 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT; 194 FilePath Append(const StringType& component) const WARN_UNUSED_RESULT;
194 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT; 195 FilePath Append(const FilePath& component) const WARN_UNUSED_RESULT;
195 196
196 // Although Windows StringType is std::wstring, since the encoding it uses for 197 // Although Windows StringType is std::wstring, since the encoding it uses for
197 // paths is well defined, it can handle ASCII path components as well. 198 // paths is well defined, it can handle ASCII path components as well.
198 // Mac uses UTF8, and since ASCII is a subset of that, it works there as well. 199 // Mac uses UTF8, and since ASCII is a subset of that, it works there as well.
199 // On Linux, although it can use any 8-bit encoding for paths, we assume that 200 // On Linux, although it can use any 8-bit encoding for paths, we assume that
200 // ASCII is a valid subset, regardless of the encoding, since many operating 201 // ASCII is a valid subset, regardless of the encoding, since many operating
201 // system paths will always be ASCII. 202 // system paths will always be ASCII.
202 FilePath AppendASCII(const std::string& component) const WARN_UNUSED_RESULT; 203 FilePath AppendASCII(const StringPiece& component) const WARN_UNUSED_RESULT;
203 204
204 // Returns true if this FilePath contains an absolute path. On Windows, an 205 // Returns true if this FilePath contains an absolute path. On Windows, an
205 // absolute path begins with either a drive letter specification followed by 206 // absolute path begins with either a drive letter specification followed by
206 // a separator character, or with two separator characters. On POSIX 207 // a separator character, or with two separator characters. On POSIX
207 // platforms, an absolute path begins with a separator character. 208 // platforms, an absolute path begins with a separator character.
208 bool IsAbsolute() const; 209 bool IsAbsolute() const;
209 210
210 // Returns a copy of this FilePath that does not end with a trailing 211 // Returns a copy of this FilePath that does not end with a trailing
211 // separator. 212 // separator.
212 FilePath StripTrailingSeparators() const; 213 FilePath StripTrailingSeparators() const;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 namespace stdext { 260 namespace stdext {
260 261
261 inline size_t hash_value(const FilePath& f) { 262 inline size_t hash_value(const FilePath& f) {
262 return hash_value(f.value()); 263 return hash_value(f.value());
263 } 264 }
264 265
265 } // namespace stdext 266 } // namespace stdext
266 #endif // COMPILER 267 #endif // COMPILER
267 268
268 #endif // BASE_FILE_PATH_H_ 269 #endif // BASE_FILE_PATH_H_
OLDNEW
« no previous file with comments | « no previous file | base/file_path.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698