Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 return false; | 686 return false; |
| 687 | 687 |
| 688 return true; | 688 return true; |
| 689 } | 689 } |
| 690 | 690 |
| 691 #if defined(OS_WIN) | 691 #if defined(OS_WIN) |
| 692 // Windows specific implementation of file string comparisons. | 692 // Windows specific implementation of file string comparisons. |
| 693 | 693 |
| 694 int FilePath::CompareIgnoreCase(StringPieceType string1, | 694 int FilePath::CompareIgnoreCase(StringPieceType string1, |
| 695 StringPieceType string2) { | 695 StringPieceType string2) { |
| 696 using CharUpperFunction = wchar_t*(WINAPI*)(wchar_t * str); | |
|
grt (UTC plus 2)
2016/06/14 02:20:49
nit: "wchar_t* str"
ananta
2016/06/14 03:24:05
Done. Thought git cl format would fix it.
| |
| 697 static CharUpperFunction char_upper_api = reinterpret_cast<CharUpperFunction>( | |
| 698 ::GetProcAddress(::GetModuleHandle(L"user32.dll"), "CharUpperW")); | |
| 699 CHECK(char_upper_api); | |
| 696 // Perform character-wise upper case comparison rather than using the | 700 // Perform character-wise upper case comparison rather than using the |
| 697 // fully Unicode-aware CompareString(). For details see: | 701 // fully Unicode-aware CompareString(). For details see: |
| 698 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx | 702 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx |
| 699 StringPieceType::const_iterator i1 = string1.begin(); | 703 StringPieceType::const_iterator i1 = string1.begin(); |
| 700 StringPieceType::const_iterator i2 = string2.begin(); | 704 StringPieceType::const_iterator i2 = string2.begin(); |
| 701 StringPieceType::const_iterator string1end = string1.end(); | 705 StringPieceType::const_iterator string1end = string1.end(); |
| 702 StringPieceType::const_iterator string2end = string2.end(); | 706 StringPieceType::const_iterator string2end = string2.end(); |
| 703 for ( ; i1 != string1end && i2 != string2end; ++i1, ++i2) { | 707 for ( ; i1 != string1end && i2 != string2end; ++i1, ++i2) { |
| 704 wchar_t c1 = | 708 wchar_t c1 = |
| 705 (wchar_t)LOWORD(::CharUpperW((LPWSTR)(DWORD_PTR)MAKELONG(*i1, 0))); | 709 (wchar_t)LOWORD(char_upper_api((LPWSTR)(DWORD_PTR)MAKELONG(*i1, 0))); |
| 706 wchar_t c2 = | 710 wchar_t c2 = |
| 707 (wchar_t)LOWORD(::CharUpperW((LPWSTR)(DWORD_PTR)MAKELONG(*i2, 0))); | 711 (wchar_t)LOWORD(char_upper_api((LPWSTR)(DWORD_PTR)MAKELONG(*i2, 0))); |
| 708 if (c1 < c2) | 712 if (c1 < c2) |
| 709 return -1; | 713 return -1; |
| 710 if (c1 > c2) | 714 if (c1 > c2) |
| 711 return 1; | 715 return 1; |
| 712 } | 716 } |
| 713 if (i1 != string1end) | 717 if (i1 != string1end) |
| 714 return 1; | 718 return 1; |
| 715 if (i2 != string2end) | 719 if (i2 != string2end) |
| 716 return -1; | 720 return -1; |
| 717 return 0; | 721 return 0; |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1323 #endif | 1327 #endif |
| 1324 } | 1328 } |
| 1325 | 1329 |
| 1326 #if defined(OS_ANDROID) | 1330 #if defined(OS_ANDROID) |
| 1327 bool FilePath::IsContentUri() const { | 1331 bool FilePath::IsContentUri() const { |
| 1328 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); | 1332 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); |
| 1329 } | 1333 } |
| 1330 #endif | 1334 #endif |
| 1331 | 1335 |
| 1332 } // namespace base | 1336 } // namespace base |
| OLD | NEW |