| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 return WideToASCII(path_); | 544 return WideToASCII(path_); |
| 545 return ""; | 545 return ""; |
| 546 } | 546 } |
| 547 | 547 |
| 548 // static | 548 // static |
| 549 FilePath FilePath::FromWStringHack(const std::wstring& wstring) { | 549 FilePath FilePath::FromWStringHack(const std::wstring& wstring) { |
| 550 return FilePath(wstring); | 550 return FilePath(wstring); |
| 551 } | 551 } |
| 552 #endif | 552 #endif |
| 553 | 553 |
| 554 // static. | 554 void FilePath::WriteToPickle(Pickle* pickle) { |
| 555 void FilePath::WriteStringTypeToPickle(Pickle* pickle, | 555 #if defined(OS_WIN) |
| 556 const StringType& path) { | 556 pickle->WriteString16(path_); |
| 557 #if defined(WCHAR_T_IS_UTF16) | |
| 558 pickle->WriteWString(path); | |
| 559 #elif defined(WCHAR_T_IS_UTF32) | |
| 560 pickle->WriteString(path); | |
| 561 #else | 557 #else |
| 562 NOTIMPLEMENTED() << "Impossible encoding situation!"; | 558 pickle->WriteString(path_); |
| 563 #endif | 559 #endif |
| 564 } | 560 } |
| 565 | 561 |
| 566 // static. | 562 bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) { |
| 567 bool FilePath::ReadStringTypeFromPickle(Pickle* pickle, void** iter, | 563 #if defined(OS_WIN) |
| 568 StringType* path) { | 564 if (!pickle->ReadString16(iter, &path_)) |
| 569 #if defined(WCHAR_T_IS_UTF16) | |
| 570 if (!pickle->ReadWString(iter, path)) | |
| 571 return false; | |
| 572 #elif defined(WCHAR_T_IS_UTF32) | |
| 573 if (!pickle->ReadString(iter, path)) | |
| 574 return false; | 565 return false; |
| 575 #else | 566 #else |
| 576 NOTIMPLEMENTED() << "Impossible encoding situation!"; | 567 if (!pickle->ReadString(iter, &path_)) |
| 577 return false; | 568 return false; |
| 578 #endif | 569 #endif |
| 579 | 570 |
| 580 return true; | 571 return true; |
| 581 } | 572 } |
| 582 | 573 |
| 583 void FilePath::WriteToPickle(Pickle* pickle) { | |
| 584 WriteStringTypeToPickle(pickle, value()); | |
| 585 } | |
| 586 | |
| 587 bool FilePath::ReadFromPickle(Pickle* pickle, void** iter) { | |
| 588 return ReadStringTypeFromPickle(pickle, iter, &path_); | |
| 589 } | |
| 590 | |
| 591 #if defined(OS_WIN) | 574 #if defined(OS_WIN) |
| 592 // Windows specific implementation of file string comparisons | 575 // Windows specific implementation of file string comparisons |
| 593 | 576 |
| 594 int FilePath::CompareIgnoreCase(const StringType& string1, | 577 int FilePath::CompareIgnoreCase(const StringType& string1, |
| 595 const StringType& string2) { | 578 const StringType& string2) { |
| 596 // Perform character-wise upper case comparison rather than using the | 579 // Perform character-wise upper case comparison rather than using the |
| 597 // fully Unicode-aware CompareString(). For details see: | 580 // fully Unicode-aware CompareString(). For details see: |
| 598 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx | 581 // http://blogs.msdn.com/michkap/archive/2005/10/17/481600.aspx |
| 599 StringType::const_iterator i1 = string1.begin(); | 582 StringType::const_iterator i1 = string1.begin(); |
| 600 StringType::const_iterator i2 = string2.begin(); | 583 StringType::const_iterator i2 = string2.begin(); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 | 1185 |
| 1203 #if defined(FILE_PATH_USES_WIN_SEPARATORS) | 1186 #if defined(FILE_PATH_USES_WIN_SEPARATORS) |
| 1204 FilePath FilePath::NormalizeWindowsPathSeparators() const { | 1187 FilePath FilePath::NormalizeWindowsPathSeparators() const { |
| 1205 StringType copy = path_; | 1188 StringType copy = path_; |
| 1206 for (size_t i = 1; i < arraysize(kSeparators); ++i) { | 1189 for (size_t i = 1; i < arraysize(kSeparators); ++i) { |
| 1207 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); | 1190 std::replace(copy.begin(), copy.end(), kSeparators[i], kSeparators[0]); |
| 1208 } | 1191 } |
| 1209 return FilePath(copy); | 1192 return FilePath(copy); |
| 1210 } | 1193 } |
| 1211 #endif | 1194 #endif |
| OLD | NEW |