OLD | NEW |
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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/pickle.h" | 12 #include "base/pickle.h" |
13 | |
14 // These includes are just for the *Hack functions, and should be removed | |
15 // when those functions are removed. | |
16 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
17 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
18 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
19 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
20 | 17 |
21 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
22 #include "base/mac/scoped_cftyperef.h" | 19 #include "base/mac/scoped_cftyperef.h" |
23 #include "base/third_party/icu/icu_utf.h" | 20 #include "base/third_party/icu/icu_utf.h" |
24 #endif | 21 #endif |
25 | 22 |
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 return CFStringCompare(cfstring1, | 1249 return CFStringCompare(cfstring1, |
1253 cfstring2, | 1250 cfstring2, |
1254 kCFCompareCaseInsensitive); | 1251 kCFCompareCaseInsensitive); |
1255 } | 1252 } |
1256 | 1253 |
1257 return HFSFastUnicodeCompare(hfs1, hfs2); | 1254 return HFSFastUnicodeCompare(hfs1, hfs2); |
1258 } | 1255 } |
1259 | 1256 |
1260 #else // << WIN. MACOSX | other (POSIX) >> | 1257 #else // << WIN. MACOSX | other (POSIX) >> |
1261 | 1258 |
1262 // Generic (POSIX) implementation of file string comparison. | 1259 // Generic Posix system comparisons. |
1263 // TODO(rolandsteiner) check if this is sufficient/correct. | |
1264 int FilePath::CompareIgnoreCase(StringPieceType string1, | 1260 int FilePath::CompareIgnoreCase(StringPieceType string1, |
1265 StringPieceType string2) { | 1261 StringPieceType string2) { |
1266 int comparison = strcasecmp(string1.data(), string2.data()); | 1262 // Specifically need null termianted strings for this API call. |
| 1263 int comparison = strcasecmp(string1.as_string().c_str(), |
| 1264 string2.as_string().c_str()); |
1267 if (comparison < 0) | 1265 if (comparison < 0) |
1268 return -1; | 1266 return -1; |
1269 if (comparison > 0) | 1267 if (comparison > 0) |
1270 return 1; | 1268 return 1; |
1271 return 0; | 1269 return 0; |
1272 } | 1270 } |
1273 | 1271 |
1274 #endif // OS versions of CompareIgnoreCase() | 1272 #endif // OS versions of CompareIgnoreCase() |
1275 | 1273 |
1276 | 1274 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 #endif | 1312 #endif |
1315 } | 1313 } |
1316 | 1314 |
1317 #if defined(OS_ANDROID) | 1315 #if defined(OS_ANDROID) |
1318 bool FilePath::IsContentUri() const { | 1316 bool FilePath::IsContentUri() const { |
1319 return StartsWithASCII(path_, "content://", false /*case_sensitive*/); | 1317 return StartsWithASCII(path_, "content://", false /*case_sensitive*/); |
1320 } | 1318 } |
1321 #endif | 1319 #endif |
1322 | 1320 |
1323 } // namespace base | 1321 } // namespace base |
OLD | NEW |