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

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

Issue 790903003: Generalizing conditional compilation logic for systems with native utf8 locale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated BUILD.gn based on rvargas comments. Created 6 years 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 | « base/base.gypi ('k') | base/strings/sys_string_conversions_posix.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) 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (base::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(SYSTEM_NATIVE_UTF8)
597 return value(); 597 return value();
598 #else 598 #else
599 return WideToUTF8(SysNativeMBToWide(value())); 599 return WideToUTF8(SysNativeMBToWide(value()));
600 #endif 600 #endif
601 } 601 }
602 602
603 string16 FilePath::AsUTF16Unsafe() const { 603 string16 FilePath::AsUTF16Unsafe() const {
604 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 604 #if defined(SYSTEM_NATIVE_UTF8)
605 return UTF8ToUTF16(value()); 605 return UTF8ToUTF16(value());
606 #else 606 #else
607 return WideToUTF16(SysNativeMBToWide(value())); 607 return WideToUTF16(SysNativeMBToWide(value()));
608 #endif 608 #endif
609 } 609 }
610 610
611 // static 611 // static
612 FilePath FilePath::FromUTF8Unsafe(const std::string& utf8) { 612 FilePath FilePath::FromUTF8Unsafe(const std::string& utf8) {
613 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 613 #if defined(SYSTEM_NATIVE_UTF8)
614 return FilePath(utf8); 614 return FilePath(utf8);
615 #else 615 #else
616 return FilePath(SysWideToNativeMB(UTF8ToWide(utf8))); 616 return FilePath(SysWideToNativeMB(UTF8ToWide(utf8)));
617 #endif 617 #endif
618 } 618 }
619 619
620 // static 620 // static
621 FilePath FilePath::FromUTF16Unsafe(const string16& utf16) { 621 FilePath FilePath::FromUTF16Unsafe(const string16& utf16) {
622 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 622 #if defined(SYSTEM_NATIVE_UTF8)
623 return FilePath(UTF16ToUTF8(utf16)); 623 return FilePath(UTF16ToUTF8(utf16));
624 #else 624 #else
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 }
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 bool FilePath::IsContentUri() const { 1315 bool FilePath::IsContentUri() const {
1316 return StartsWithASCII(path_, "content://", false /*case_sensitive*/); 1316 return StartsWithASCII(path_, "content://", false /*case_sensitive*/);
1317 } 1317 }
1318 #endif 1318 #endif
1319 1319
1320 } // namespace base 1320 } // namespace base
1321 1321
1322 void PrintTo(const base::FilePath& path, std::ostream* out) { 1322 void PrintTo(const base::FilePath& path, std::ostream* out) {
1323 *out << path.value(); 1323 *out << path.value();
1324 } 1324 }
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/strings/sys_string_conversions_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698