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

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

Issue 17618003: mac: Remove ScopedCFTypeRef from base::mac::. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ios Created 7 years, 6 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/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) 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 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 return (codepoint1 < codepoint2) ? -1 : 1; 1164 return (codepoint1 < codepoint2) ? -1 : 1;
1165 if (codepoint1 == 0) { 1165 if (codepoint1 == 0) {
1166 DCHECK_EQ(index1, length1); 1166 DCHECK_EQ(index1, length1);
1167 DCHECK_EQ(index2, length2); 1167 DCHECK_EQ(index2, length2);
1168 return 0; 1168 return 0;
1169 } 1169 }
1170 } 1170 }
1171 } 1171 }
1172 1172
1173 StringType FilePath::GetHFSDecomposedForm(const StringType& string) { 1173 StringType FilePath::GetHFSDecomposedForm(const StringType& string) {
1174 mac::ScopedCFTypeRef<CFStringRef> cfstring( 1174 ScopedCFTypeRef<CFStringRef> cfstring(
1175 CFStringCreateWithBytesNoCopy( 1175 CFStringCreateWithBytesNoCopy(
1176 NULL, 1176 NULL,
1177 reinterpret_cast<const UInt8*>(string.c_str()), 1177 reinterpret_cast<const UInt8*>(string.c_str()),
1178 string.length(), 1178 string.length(),
1179 kCFStringEncodingUTF8, 1179 kCFStringEncodingUTF8,
1180 false, 1180 false,
1181 kCFAllocatorNull)); 1181 kCFAllocatorNull));
1182 // Query the maximum length needed to store the result. In most cases this 1182 // Query the maximum length needed to store the result. In most cases this
1183 // will overestimate the required space. The return value also already 1183 // will overestimate the required space. The return value also already
1184 // includes the space needed for a terminating 0. 1184 // includes the space needed for a terminating 0.
(...skipping 26 matching lines...) Expand all
1211 return string2.empty() ? 0 : -1; 1211 return string2.empty() ? 0 : -1;
1212 if (string2.empty()) 1212 if (string2.empty())
1213 return 1; 1213 return 1;
1214 1214
1215 StringType hfs1 = GetHFSDecomposedForm(string1); 1215 StringType hfs1 = GetHFSDecomposedForm(string1);
1216 StringType hfs2 = GetHFSDecomposedForm(string2); 1216 StringType hfs2 = GetHFSDecomposedForm(string2);
1217 1217
1218 // GetHFSDecomposedForm() returns an empty string in an error case. 1218 // GetHFSDecomposedForm() returns an empty string in an error case.
1219 if (hfs1.empty() || hfs2.empty()) { 1219 if (hfs1.empty() || hfs2.empty()) {
1220 NOTREACHED(); 1220 NOTREACHED();
1221 mac::ScopedCFTypeRef<CFStringRef> cfstring1( 1221 ScopedCFTypeRef<CFStringRef> cfstring1(
1222 CFStringCreateWithBytesNoCopy( 1222 CFStringCreateWithBytesNoCopy(
1223 NULL, 1223 NULL,
1224 reinterpret_cast<const UInt8*>(string1.c_str()), 1224 reinterpret_cast<const UInt8*>(string1.c_str()),
1225 string1.length(), 1225 string1.length(),
1226 kCFStringEncodingUTF8, 1226 kCFStringEncodingUTF8,
1227 false, 1227 false,
1228 kCFAllocatorNull)); 1228 kCFAllocatorNull));
1229 mac::ScopedCFTypeRef<CFStringRef> cfstring2( 1229 ScopedCFTypeRef<CFStringRef> cfstring2(
1230 CFStringCreateWithBytesNoCopy( 1230 CFStringCreateWithBytesNoCopy(
1231 NULL, 1231 NULL,
1232 reinterpret_cast<const UInt8*>(string2.c_str()), 1232 reinterpret_cast<const UInt8*>(string2.c_str()),
1233 string2.length(), 1233 string2.length(),
1234 kCFStringEncodingUTF8, 1234 kCFStringEncodingUTF8,
1235 false, 1235 false,
1236 kCFAllocatorNull)); 1236 kCFAllocatorNull));
1237 return CFStringCompare(cfstring1, 1237 return CFStringCompare(cfstring1,
1238 cfstring2, 1238 cfstring2,
1239 kCFCompareCaseInsensitive); 1239 kCFCompareCaseInsensitive);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 #else 1291 #else
1292 return *this; 1292 return *this;
1293 #endif 1293 #endif
1294 } 1294 }
1295 1295
1296 } // namespace base 1296 } // namespace base
1297 1297
1298 void PrintTo(const base::FilePath& path, std::ostream* out) { 1298 void PrintTo(const base::FilePath& path, std::ostream* out) {
1299 *out << path.value(); 1299 *out << path.value();
1300 } 1300 }
OLDNEW
« no previous file with comments | « no previous file | base/mac/scoped_cftyperef.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698