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 #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 Loading... |
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 { | 255 FilePath FilePath::AppendASCII(const StringPiece& component) const { |
256 DCHECK(IsStringASCII(component)); | 256 DCHECK(IsStringASCII(component)); |
257 #if defined(OS_WIN) | 257 #if defined(OS_WIN) |
258 return Append(ASCIIToWide(component)); | 258 return Append(ASCIIToWide(component)); |
259 #elif defined(OS_POSIX) | 259 #elif defined(OS_POSIX) |
260 return Append(component); | 260 return Append(component.as_string()); |
261 #endif | 261 #endif |
262 } | 262 } |
263 | 263 |
264 bool FilePath::IsAbsolute() const { | 264 bool FilePath::IsAbsolute() const { |
265 return IsPathAbsolute(path_); | 265 return IsPathAbsolute(path_); |
266 } | 266 } |
267 | 267 |
268 #if defined(OS_POSIX) | 268 #if defined(OS_POSIX) |
269 // 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 |
270 // platforms. These *Hack() functions are not quite correct, but they're | 270 // platforms. These *Hack() functions are not quite correct, but they're |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 --pos) { | 309 --pos) { |
310 // 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, |
311 // 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. |
312 if (pos != start + 1 || last_stripped == start + 2 || | 312 if (pos != start + 1 || last_stripped == start + 2 || |
313 !IsSeparator(path_[start - 1])) { | 313 !IsSeparator(path_[start - 1])) { |
314 path_.resize(pos - 1); | 314 path_.resize(pos - 1); |
315 last_stripped = pos; | 315 last_stripped = pos; |
316 } | 316 } |
317 } | 317 } |
318 } | 318 } |
OLD | NEW |