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

Side by Side Diff: base/i18n/file_util_icu.cc

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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
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 // File utilities that use the ICU library go in this file. 5 // File utilities that use the ICU library go in this file.
6 6
7 #include "base/i18n/file_util_icu.h" 7 #include "base/i18n/file_util_icu.h"
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/i18n/icu_string_conversions.h" 10 #include "base/i18n/icu_string_conversions.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool LocaleAwareCompareFilenames(const FilePath& a, const FilePath& b) { 145 bool LocaleAwareCompareFilenames(const FilePath& a, const FilePath& b) {
146 UErrorCode error_code = U_ZERO_ERROR; 146 UErrorCode error_code = U_ZERO_ERROR;
147 // Use the default collator. The default locale should have been properly 147 // Use the default collator. The default locale should have been properly
148 // set by the time this constructor is called. 148 // set by the time this constructor is called.
149 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error_code)); 149 scoped_ptr<icu::Collator> collator(icu::Collator::createInstance(error_code));
150 DCHECK(U_SUCCESS(error_code)); 150 DCHECK(U_SUCCESS(error_code));
151 // Make it case-sensitive. 151 // Make it case-sensitive.
152 collator->setStrength(icu::Collator::TERTIARY); 152 collator->setStrength(icu::Collator::TERTIARY);
153 153
154 #if defined(OS_WIN) 154 #if defined(OS_WIN)
155 return CompareString16WithCollator(collator.get(), 155 return CompareString16WithCollator(*collator, WideToUTF16(a.value()),
156 WideToUTF16(a.value()), WideToUTF16(b.value())) == UCOL_LESS; 156 WideToUTF16(b.value())) == UCOL_LESS;
157 157
158 #elif defined(OS_POSIX) 158 #elif defined(OS_POSIX)
159 // On linux, the file system encoding is not defined. We assume 159 // On linux, the file system encoding is not defined. We assume
160 // SysNativeMBToWide takes care of it. 160 // SysNativeMBToWide takes care of it.
161 return CompareString16WithCollator( 161 return CompareString16WithCollator(
162 collator.get(), 162 *collator, WideToUTF16(SysNativeMBToWide(a.value().c_str())),
163 WideToUTF16(SysNativeMBToWide(a.value().c_str())), 163 WideToUTF16(SysNativeMBToWide(b.value().c_str()))) == UCOL_LESS;
164 WideToUTF16(SysNativeMBToWide(b.value().c_str()))) == UCOL_LESS;
165 #else 164 #else
166 #error Not implemented on your system 165 #error Not implemented on your system
167 #endif 166 #endif
168 } 167 }
169 168
170 void NormalizeFileNameEncoding(FilePath* file_name) { 169 void NormalizeFileNameEncoding(FilePath* file_name) {
171 #if defined(OS_CHROMEOS) 170 #if defined(OS_CHROMEOS)
172 std::string normalized_str; 171 std::string normalized_str;
173 if (ConvertToUtf8AndNormalize(file_name->BaseName().value(), 172 if (ConvertToUtf8AndNormalize(file_name->BaseName().value(),
174 kCodepageUTF8, 173 kCodepageUTF8,
175 &normalized_str)) { 174 &normalized_str)) {
176 *file_name = file_name->DirName().Append(FilePath(normalized_str)); 175 *file_name = file_name->DirName().Append(FilePath(normalized_str));
177 } 176 }
178 #endif 177 #endif
179 } 178 }
180 179
181 } // namespace i18n 180 } // namespace i18n
182 } // namespace base 181 } // namespace base
OLDNEW
« no previous file with comments | « base/float_util.h ('k') | base/i18n/icu_util.h » ('j') | mojo/public/tools/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698