| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/icu_util.h" | 13 #include "base/icu_util.h" |
| 14 | 14 |
| 15 #include "base/file_path.h" |
| 16 #include "base/file_util.h" |
| 15 #include "base/logging.h" | 17 #include "base/logging.h" |
| 16 #include "base/file_util.h" | |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/sys_string_conversions.h" | 19 #include "base/sys_string_conversions.h" |
| 19 #include "unicode/putil.h" | 20 #include "unicode/putil.h" |
| 20 #include "unicode/udata.h" | 21 #include "unicode/udata.h" |
| 21 | 22 |
| 22 #define ICU_UTIL_DATA_FILE 0 | 23 #define ICU_UTIL_DATA_FILE 0 |
| 23 #define ICU_UTIL_DATA_SHARED 1 | 24 #define ICU_UTIL_DATA_SHARED 1 |
| 24 #define ICU_UTIL_DATA_STATIC 2 | 25 #define ICU_UTIL_DATA_STATIC 2 |
| 25 | 26 |
| 26 #ifndef ICU_UTIL_DATA_IMPL | 27 #ifndef ICU_UTIL_DATA_IMPL |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 UErrorCode err = U_ZERO_ERROR; | 70 UErrorCode err = U_ZERO_ERROR; |
| 70 udata_setCommonData(reinterpret_cast<void*>(addr), &err); | 71 udata_setCommonData(reinterpret_cast<void*>(addr), &err); |
| 71 return err == U_ZERO_ERROR; | 72 return err == U_ZERO_ERROR; |
| 72 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) | 73 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC) |
| 73 // Mac bundles the ICU data in. | 74 // Mac bundles the ICU data in. |
| 74 return true; | 75 return true; |
| 75 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) | 76 #elif (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) |
| 76 // For now, expect the data file to be alongside the executable. | 77 // For now, expect the data file to be alongside the executable. |
| 77 // This is sufficient while we work on unit tests, but will eventually | 78 // This is sufficient while we work on unit tests, but will eventually |
| 78 // likely live in a data directory. | 79 // likely live in a data directory. |
| 79 std::wstring data_path; | 80 FilePath data_path; |
| 80 bool path_ok = PathService::Get(base::DIR_EXE, &data_path); | 81 bool path_ok = PathService::Get(base::DIR_EXE, &data_path); |
| 81 DCHECK(path_ok); | 82 DCHECK(path_ok); |
| 82 u_setDataDirectory(base::SysWideToNativeMB(data_path).c_str()); | 83 u_setDataDirectory( |
| 84 base::SysWideToNativeMB(data_path.ToWStringHack()).c_str()); |
| 83 // Only look for the packaged data file; | 85 // Only look for the packaged data file; |
| 84 // the default behavior is to look for individual files. | 86 // the default behavior is to look for individual files. |
| 85 UErrorCode err = U_ZERO_ERROR; | 87 UErrorCode err = U_ZERO_ERROR; |
| 86 udata_setFileAccess(UDATA_ONLY_PACKAGES, &err); | 88 udata_setFileAccess(UDATA_ONLY_PACKAGES, &err); |
| 87 return err == U_ZERO_ERROR; | 89 return err == U_ZERO_ERROR; |
| 88 #endif | 90 #endif |
| 89 } | 91 } |
| 90 | 92 |
| 91 } // namespace icu_util | 93 } // namespace icu_util |
| 92 | 94 |
| OLD | NEW |