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 static decltype(::CharUpperW)* const char_upper_api = | |
697 reinterpret_cast<decltype(::CharUpperW)*>( | |
698 ::GetProcAddress(::GetModuleHandle(L"user32.dll"), "CharUpperW")); | |
699 CHECK(char_upper_api); | |
700 // Perform character-wise upper case comparison rather than using the | 696 // Perform character-wise upper case comparison rather than using the |
701 // fully Unicode-aware CompareString(). For details see: | 697 // fully Unicode-aware CompareString(). For details see: |
702 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx | 698 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx |
703 StringPieceType::const_iterator i1 = string1.begin(); | 699 StringPieceType::const_iterator i1 = string1.begin(); |
704 StringPieceType::const_iterator i2 = string2.begin(); | 700 StringPieceType::const_iterator i2 = string2.begin(); |
705 StringPieceType::const_iterator string1end = string1.end(); | 701 StringPieceType::const_iterator string1end = string1.end(); |
706 StringPieceType::const_iterator string2end = string2.end(); | 702 StringPieceType::const_iterator string2end = string2.end(); |
707 for ( ; i1 != string1end && i2 != string2end; ++i1, ++i2) { | 703 for ( ; i1 != string1end && i2 != string2end; ++i1, ++i2) { |
708 wchar_t c1 = | 704 wchar_t c1 = |
709 (wchar_t)LOWORD(char_upper_api((LPWSTR)(DWORD_PTR)MAKELONG(*i1, 0))); | 705 (wchar_t)LOWORD(::CharUpperW((LPWSTR)(DWORD_PTR)MAKELONG(*i1, 0))); |
710 wchar_t c2 = | 706 wchar_t c2 = |
711 (wchar_t)LOWORD(char_upper_api((LPWSTR)(DWORD_PTR)MAKELONG(*i2, 0))); | 707 (wchar_t)LOWORD(::CharUpperW((LPWSTR)(DWORD_PTR)MAKELONG(*i2, 0))); |
712 if (c1 < c2) | 708 if (c1 < c2) |
713 return -1; | 709 return -1; |
714 if (c1 > c2) | 710 if (c1 > c2) |
715 return 1; | 711 return 1; |
716 } | 712 } |
717 if (i1 != string1end) | 713 if (i1 != string1end) |
718 return 1; | 714 return 1; |
719 if (i2 != string2end) | 715 if (i2 != string2end) |
720 return -1; | 716 return -1; |
721 return 0; | 717 return 0; |
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 #endif | 1323 #endif |
1328 } | 1324 } |
1329 | 1325 |
1330 #if defined(OS_ANDROID) | 1326 #if defined(OS_ANDROID) |
1331 bool FilePath::IsContentUri() const { | 1327 bool FilePath::IsContentUri() const { |
1332 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); | 1328 return StartsWith(path_, "content://", base::CompareCase::INSENSITIVE_ASCII); |
1333 } | 1329 } |
1334 #endif | 1330 #endif |
1335 | 1331 |
1336 } // namespace base | 1332 } // namespace base |
OLD | NEW |