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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 StringType ext = Extension(); | 306 StringType ext = Extension(); |
307 StringType ret = RemoveExtension().value(); | 307 StringType ret = RemoveExtension().value(); |
308 ret.append(suffix); | 308 ret.append(suffix); |
309 ret.append(ext); | 309 ret.append(ext); |
310 return FilePath(ret); | 310 return FilePath(ret); |
311 } | 311 } |
312 | 312 |
313 FilePath FilePath::InsertBeforeExtensionASCII(const StringPiece& suffix) const { | 313 FilePath FilePath::InsertBeforeExtensionASCII(const base::StringPiece& suffix) |
| 314 const { |
314 DCHECK(IsStringASCII(suffix)); | 315 DCHECK(IsStringASCII(suffix)); |
315 #if defined(OS_WIN) | 316 #if defined(OS_WIN) |
316 return InsertBeforeExtension(ASCIIToWide(suffix)); | 317 return InsertBeforeExtension(ASCIIToWide(suffix)); |
317 #elif defined(OS_POSIX) | 318 #elif defined(OS_POSIX) |
318 return InsertBeforeExtension(suffix.as_string()); | 319 return InsertBeforeExtension(suffix.as_string()); |
319 #endif | 320 #endif |
320 } | 321 } |
321 | 322 |
322 FilePath FilePath::ReplaceExtension(const StringType& extension) const { | 323 FilePath FilePath::ReplaceExtension(const StringType& extension) const { |
323 if (path_.empty()) | 324 if (path_.empty()) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 391 } |
391 | 392 |
392 new_path.path_.append(component); | 393 new_path.path_.append(component); |
393 return new_path; | 394 return new_path; |
394 } | 395 } |
395 | 396 |
396 FilePath FilePath::Append(const FilePath& component) const { | 397 FilePath FilePath::Append(const FilePath& component) const { |
397 return Append(component.value()); | 398 return Append(component.value()); |
398 } | 399 } |
399 | 400 |
400 FilePath FilePath::AppendASCII(const StringPiece& component) const { | 401 FilePath FilePath::AppendASCII(const base::StringPiece& component) const { |
401 DCHECK(IsStringASCII(component)); | 402 DCHECK(IsStringASCII(component)); |
402 #if defined(OS_WIN) | 403 #if defined(OS_WIN) |
403 return Append(ASCIIToWide(component)); | 404 return Append(ASCIIToWide(component)); |
404 #elif defined(OS_POSIX) | 405 #elif defined(OS_POSIX) |
405 return Append(component.as_string()); | 406 return Append(component.as_string()); |
406 #endif | 407 #endif |
407 } | 408 } |
408 | 409 |
409 bool FilePath::IsAbsolute() const { | 410 bool FilePath::IsAbsolute() const { |
410 return IsPathAbsolute(path_); | 411 return IsPathAbsolute(path_); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 469 |
469 std::vector<FilePath::StringType>::const_iterator it = components.begin(); | 470 std::vector<FilePath::StringType>::const_iterator it = components.begin(); |
470 for (; it != components.end(); ++it) { | 471 for (; it != components.end(); ++it) { |
471 const FilePath::StringType& component = *it; | 472 const FilePath::StringType& component = *it; |
472 if (component == kParentDirectory) | 473 if (component == kParentDirectory) |
473 return true; | 474 return true; |
474 } | 475 } |
475 return false; | 476 return false; |
476 } | 477 } |
477 | 478 |
OLD | NEW |