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

Side by Side Diff: base/file_path.cc

Issue 3855001: Move scoped_cftyperef from base to base/mac, use the new namespace, and name ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | « app/surface/accelerated_surface_mac.cc ('k') | base/mac/scoped_cftyperef.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(OS_MACOSX) 9 #elif defined(OS_MACOSX)
10 #include <CoreServices/CoreServices.h> 10 #include <CoreServices/CoreServices.h>
11 #endif 11 #endif
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/pickle.h" 14 #include "base/pickle.h"
15 15
16 // These includes are just for the *Hack functions, and should be removed 16 // These includes are just for the *Hack functions, and should be removed
17 // when those functions are removed. 17 // when those functions are removed.
18 #include "base/string_piece.h" 18 #include "base/string_piece.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/sys_string_conversions.h" 20 #include "base/sys_string_conversions.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 22
23 #if defined(OS_MACOSX) 23 #if defined(OS_MACOSX)
24 #include "base/scoped_cftyperef.h" 24 #include "base/mac/scoped_cftyperef.h"
25 #include "base/third_party/icu/icu_utf.h" 25 #include "base/third_party/icu/icu_utf.h"
26 #endif 26 #endif
27 27
28 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 28 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
29 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/"); 29 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("\\/");
30 #else // FILE_PATH_USES_WIN_SEPARATORS 30 #else // FILE_PATH_USES_WIN_SEPARATORS
31 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/"); 31 const FilePath::CharType FilePath::kSeparators[] = FILE_PATH_LITERAL("/");
32 #endif // FILE_PATH_USES_WIN_SEPARATORS 32 #endif // FILE_PATH_USES_WIN_SEPARATORS
33 33
34 const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL("."); 34 const FilePath::CharType FilePath::kCurrentDirectory[] = FILE_PATH_LITERAL(".");
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 return (codepoint1 < codepoint2) ? -1 : 1; 984 return (codepoint1 < codepoint2) ? -1 : 1;
985 if (codepoint1 == 0) { 985 if (codepoint1 == 0) {
986 DCHECK_EQ(index1, length1); 986 DCHECK_EQ(index1, length1);
987 DCHECK_EQ(index2, length2); 987 DCHECK_EQ(index2, length2);
988 return 0; 988 return 0;
989 } 989 }
990 } 990 }
991 } 991 }
992 992
993 StringType FilePath::GetHFSDecomposedForm(const StringType& string) { 993 StringType FilePath::GetHFSDecomposedForm(const StringType& string) {
994 scoped_cftyperef<CFStringRef> cfstring( 994 base::mac::ScopedCFTypeRef<CFStringRef> cfstring(
995 CFStringCreateWithBytesNoCopy( 995 CFStringCreateWithBytesNoCopy(
996 NULL, 996 NULL,
997 reinterpret_cast<const UInt8*>(string.c_str()), 997 reinterpret_cast<const UInt8*>(string.c_str()),
998 string.length(), 998 string.length(),
999 kCFStringEncodingUTF8, 999 kCFStringEncodingUTF8,
1000 false, 1000 false,
1001 kCFAllocatorNull)); 1001 kCFAllocatorNull));
1002 // Query the maximum length needed to store the result. In most cases this 1002 // Query the maximum length needed to store the result. In most cases this
1003 // will overestimate the required space. The return value also already 1003 // will overestimate the required space. The return value also already
1004 // includes the space needed for a terminating 0. 1004 // includes the space needed for a terminating 0.
(...skipping 26 matching lines...) Expand all
1031 return string2.empty() ? 0 : -1; 1031 return string2.empty() ? 0 : -1;
1032 if (string2.empty()) 1032 if (string2.empty())
1033 return 1; 1033 return 1;
1034 1034
1035 StringType hfs1 = GetHFSDecomposedForm(string1); 1035 StringType hfs1 = GetHFSDecomposedForm(string1);
1036 StringType hfs2 = GetHFSDecomposedForm(string2); 1036 StringType hfs2 = GetHFSDecomposedForm(string2);
1037 1037
1038 // GetHFSDecomposedForm() returns an empty string in an error case. 1038 // GetHFSDecomposedForm() returns an empty string in an error case.
1039 if (hfs1.empty() || hfs2.empty()) { 1039 if (hfs1.empty() || hfs2.empty()) {
1040 NOTREACHED(); 1040 NOTREACHED();
1041 scoped_cftyperef<CFStringRef> cfstring1( 1041 base::mac::ScopedCFTypeRef<CFStringRef> cfstring1(
1042 CFStringCreateWithBytesNoCopy( 1042 CFStringCreateWithBytesNoCopy(
1043 NULL, 1043 NULL,
1044 reinterpret_cast<const UInt8*>(string1.c_str()), 1044 reinterpret_cast<const UInt8*>(string1.c_str()),
1045 string1.length(), 1045 string1.length(),
1046 kCFStringEncodingUTF8, 1046 kCFStringEncodingUTF8,
1047 false, 1047 false,
1048 kCFAllocatorNull)); 1048 kCFAllocatorNull));
1049 scoped_cftyperef<CFStringRef> cfstring2( 1049 base::mac::ScopedCFTypeRef<CFStringRef> cfstring2(
1050 CFStringCreateWithBytesNoCopy( 1050 CFStringCreateWithBytesNoCopy(
1051 NULL, 1051 NULL,
1052 reinterpret_cast<const UInt8*>(string2.c_str()), 1052 reinterpret_cast<const UInt8*>(string2.c_str()),
1053 string2.length(), 1053 string2.length(),
1054 kCFStringEncodingUTF8, 1054 kCFStringEncodingUTF8,
1055 false, 1055 false,
1056 kCFAllocatorNull)); 1056 kCFAllocatorNull));
1057 return CFStringCompare(cfstring1, 1057 return CFStringCompare(cfstring1,
1058 cfstring2, 1058 cfstring2,
1059 kCFCompareCaseInsensitive); 1059 kCFCompareCaseInsensitive);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1183
1184 #if defined(FILE_PATH_USES_WIN_SEPARATORS) 1184 #if defined(FILE_PATH_USES_WIN_SEPARATORS)
1185 FilePath FilePath::NormalizeWindowsPathSeparators() const { 1185 FilePath FilePath::NormalizeWindowsPathSeparators() const {
1186 StringType copy = path_; 1186 StringType copy = path_;
1187 for (size_t i = 1; i < arraysize(kSeparators); ++i) { 1187 for (size_t i = 1; i < arraysize(kSeparators); ++i) {
1188 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); 1188 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]);
1189 } 1189 }
1190 return FilePath(copy); 1190 return FilePath(copy);
1191 } 1191 }
1192 #endif 1192 #endif
OLDNEW
« no previous file with comments | « app/surface/accelerated_surface_mac.cc ('k') | base/mac/scoped_cftyperef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698