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

Side by Side Diff: base/files/file_path.cc

Issue 270183002: Move IsStringUTF8/ASCII to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more minor nit Created 6 years, 7 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 | « no previous file | base/strings/string_util.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/files/file_path.h" 5 #include "base/files/file_path.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 514
515 new_path.path_.append(*appended); 515 new_path.path_.append(*appended);
516 return new_path; 516 return new_path;
517 } 517 }
518 518
519 FilePath FilePath::Append(const FilePath& component) const { 519 FilePath FilePath::Append(const FilePath& component) const {
520 return Append(component.value()); 520 return Append(component.value());
521 } 521 }
522 522
523 FilePath FilePath::AppendASCII(const StringPiece& component) const { 523 FilePath FilePath::AppendASCII(const StringPiece& component) const {
524 DCHECK(IsStringASCII(component)); 524 DCHECK(base::IsStringASCII(component));
525 #if defined(OS_WIN) 525 #if defined(OS_WIN)
526 return Append(ASCIIToUTF16(component.as_string())); 526 return Append(ASCIIToUTF16(component.as_string()));
527 #elif defined(OS_POSIX) 527 #elif defined(OS_POSIX)
528 return Append(component.as_string()); 528 return Append(component.as_string());
529 #endif 529 #endif
530 } 530 }
531 531
532 bool FilePath::IsAbsolute() const { 532 bool FilePath::IsAbsolute() const {
533 return IsPathAbsolute(path_); 533 return IsPathAbsolute(path_);
534 } 534 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 580
581 #if defined(OS_POSIX) 581 #if defined(OS_POSIX)
582 // See file_path.h for a discussion of the encoding of paths on POSIX 582 // See file_path.h for a discussion of the encoding of paths on POSIX
583 // platforms. These encoding conversion functions are not quite correct. 583 // platforms. These encoding conversion functions are not quite correct.
584 584
585 string16 FilePath::LossyDisplayName() const { 585 string16 FilePath::LossyDisplayName() const {
586 return WideToUTF16(SysNativeMBToWide(path_)); 586 return WideToUTF16(SysNativeMBToWide(path_));
587 } 587 }
588 588
589 std::string FilePath::MaybeAsASCII() const { 589 std::string FilePath::MaybeAsASCII() const {
590 if (IsStringASCII(path_)) 590 if (base::IsStringASCII(path_))
591 return path_; 591 return path_;
592 return std::string(); 592 return std::string();
593 } 593 }
594 594
595 std::string FilePath::AsUTF8Unsafe() const { 595 std::string FilePath::AsUTF8Unsafe() const {
596 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 596 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
597 return value(); 597 return value();
598 #else 598 #else
599 return WideToUTF8(SysNativeMBToWide(value())); 599 return WideToUTF8(SysNativeMBToWide(value()));
600 #endif 600 #endif
(...skipping 24 matching lines...) Expand all
625 return FilePath(SysWideToNativeMB(UTF16ToWide(utf16))); 625 return FilePath(SysWideToNativeMB(UTF16ToWide(utf16)));
626 #endif 626 #endif
627 } 627 }
628 628
629 #elif defined(OS_WIN) 629 #elif defined(OS_WIN)
630 string16 FilePath::LossyDisplayName() const { 630 string16 FilePath::LossyDisplayName() const {
631 return path_; 631 return path_;
632 } 632 }
633 633
634 std::string FilePath::MaybeAsASCII() const { 634 std::string FilePath::MaybeAsASCII() const {
635 if (IsStringASCII(path_)) 635 if (base::IsStringASCII(path_))
636 return UTF16ToASCII(path_); 636 return UTF16ToASCII(path_);
637 return std::string(); 637 return std::string();
638 } 638 }
639 639
640 std::string FilePath::AsUTF8Unsafe() const { 640 std::string FilePath::AsUTF8Unsafe() const {
641 return WideToUTF8(value()); 641 return WideToUTF8(value());
642 } 642 }
643 643
644 string16 FilePath::AsUTF16Unsafe() const { 644 string16 FilePath::AsUTF16Unsafe() const {
645 return value(); 645 return value();
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 bool FilePath::IsContentUri() const { 1313 bool FilePath::IsContentUri() const {
1314 return StartsWithASCII(path_, "content://", false /*case_sensitive*/); 1314 return StartsWithASCII(path_, "content://", false /*case_sensitive*/);
1315 } 1315 }
1316 #endif 1316 #endif
1317 1317
1318 } // namespace base 1318 } // namespace base
1319 1319
1320 void PrintTo(const base::FilePath& path, std::ostream* out) { 1320 void PrintTo(const base::FilePath& path, std::ostream* out) {
1321 *out << path.value(); 1321 *out << path.value();
1322 } 1322 }
OLDNEW
« no previous file with comments | « no previous file | base/strings/string_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698