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

Side by Side Diff: base/file_path.cc

Issue 18134: Add AppendASCII (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « base/file_path.h ('k') | base/file_path_unittest.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 #include "base/file_path.h" 5 #include "base/file_path.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 7
8 // These includes are just for the *Hack functions, and should be removed 8 // These includes are just for the *Hack functions, and should be removed
9 // when those functions are removed. 9 // when those functions are removed.
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 new_path.path_.append(component); 247 new_path.path_.append(component);
248 return new_path; 248 return new_path;
249 } 249 }
250 250
251 FilePath FilePath::Append(const FilePath& component) const { 251 FilePath FilePath::Append(const FilePath& component) const {
252 return Append(component.value()); 252 return Append(component.value());
253 } 253 }
254 254
255 FilePath FilePath::AppendASCII(const std::string& component) const {
256 DCHECK(IsStringASCII(component));
257 #if defined(OS_WIN)
258 return Append(ASCIIToWide(component));
259 #elif defined(OS_POSIX)
260 return Append(component);
261 #endif
262 }
263
255 bool FilePath::IsAbsolute() const { 264 bool FilePath::IsAbsolute() const {
256 return IsPathAbsolute(path_); 265 return IsPathAbsolute(path_);
257 } 266 }
258 267
259 #if defined(OS_POSIX) 268 #if defined(OS_POSIX)
260 // See file_path.h for a discussion of the encoding of paths on POSIX 269 // See file_path.h for a discussion of the encoding of paths on POSIX
261 // platforms. These *Hack() functions are not quite correct, but they're 270 // platforms. These *Hack() functions are not quite correct, but they're
262 // only temporary while we fix the remainder of the code. 271 // only temporary while we fix the remainder of the code.
263 // Remember to remove the #includes at the top when you remove these. 272 // Remember to remove the #includes at the top when you remove these.
264 273
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 --pos) { 309 --pos) {
301 // If the string only has two separators and they're at the beginning, 310 // If the string only has two separators and they're at the beginning,
302 // don't strip them, unless the string began with more than two separators. 311 // don't strip them, unless the string began with more than two separators.
303 if (pos != start + 1 || last_stripped == start + 2 || 312 if (pos != start + 1 || last_stripped == start + 2 ||
304 !IsSeparator(path_[start - 1])) { 313 !IsSeparator(path_[start - 1])) {
305 path_.resize(pos - 1); 314 path_.resize(pos - 1);
306 last_stripped = pos; 315 last_stripped = pos;
307 } 316 }
308 } 317 }
309 } 318 }
OLDNEW
« no previous file with comments | « base/file_path.h ('k') | base/file_path_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698