!248 时区文件读取失败

Merge pull request !248 from zhangdd_ewan/cherry-240712
This commit is contained in:
openharmony_ci 2024-07-15 02:56:30 +00:00 committed by Gitee
commit 2cd3423e24
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 24 additions and 13 deletions

View File

@ -15,4 +15,6 @@ declare_args() {
icu_support_locales = true
build_feature = "normal"
icu_support_libbegetutil = true
distro_tzdata_dir = "\"/system/etc/tzdata_distro\""
system_tzdata_dir = "\"/system/etc/icu_tzdata\""
}

View File

@ -539,6 +539,8 @@ ohos_shared_library("shared_icuuc") {
"UPRV_BLOCK_MACRO_END=",
"UCONFIG_USE_WINDOWS_LCID_MAPPING_API=0",
"_REENTRANT",
"DISTRO_TZDATA_DIR=${distro_tzdata_dir}",
"SYSTEM_TZDATA_DIR=${system_tzdata_dir}",
]
if (!is_mingw) {
defines += [ "ICU_SUPPORT_DISTRO" ]

View File

@ -1308,16 +1308,29 @@ doOpenChoice(const char *path, const char *type, const char *name,
/**** Time zone individual files override */
if (isICUData && isTimeZoneFile(name, type)) {
#ifdef DISTRO_TZDATA_DIR
const char* distroTzdataDir = DISTRO_TZDATA_DIR;
retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", distroTzdataDir, tocEntryPathSuffix,
/* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode);
if((retVal != NULL) || U_FAILURE(*pErrorCode)) {
return retVal;
}
#endif
#ifdef SYSTEM_TZDATA_DIR
const char* systemTzdataDir = SYSTEM_TZDATA_DIR;
retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", systemTzdataDir, tocEntryPathSuffix,
/* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode);
if((retVal != NULL) || U_FAILURE(*pErrorCode)) {
return retVal;
}
#endif
const char *tzFilesDir = u_getTimeZoneFilesDirectory(pErrorCode);
if (tzFilesDir[0] != 0) {
#ifdef UDATA_DEBUG
fprintf(stderr, "Trying Time Zone Files directory = %s\n", tzFilesDir);
#endif
retVal = doLoadFromIndividualFiles(/* pkgName.data() */ "", tzFilesDir, tocEntryPathSuffix,
/* path */ "", type, name, isAcceptable, context, &subErrorCode, pErrorCode);
if((retVal != NULL) || U_FAILURE(*pErrorCode)) {
return retVal;
}
retVal = doLoadFromCommonData(isICUData,
"icu_tzdata", tzFilesDir, tocEntryPathSuffix, tocEntryName.data(),
"icu_tzdata", type, name, isAcceptable, context, &subErrorCode, pErrorCode);

View File

@ -22,20 +22,14 @@
namespace OHOS {
namespace Global {
namespace I18n {
const char *DistroTZDataLoader::ICU_TZDATA_PATH = "/system/etc/tzdata_distro/icu/icu_tzdata.dat";
const char *DistroTZDataLoader::DISTRO_TZDATA_PATH = "/system/etc/tzdata_distro/icu";
const char *DistroTZDataLoader::ICU_TZDATA_PATH = "/system/etc/tzdata_distro/icu_tzdata.dat";
const char *DistroTZDataLoader::DISTRO_TZDATA_PATH = "/system/etc/tzdata_distro";
const char *DistroTZDataLoader::TZDATA_PATH = "/system/etc/icu_tzdata";
const char *DistroTZDataLoader::ICU_TIMEZONE_FILES_DIR = "ICU_TIMEZONE_FILES_DIR";
void DistroTZDataLoader::SetDistroTZDataPath()
{
#ifdef ICU_SUPPORT_DISTRO
// if distro_tzdata_path is exist, use distro tzdata first
if (CheckFileExist()) {
setenv(ICU_TIMEZONE_FILES_DIR, DISTRO_TZDATA_PATH, 1);
} else {
setenv(ICU_TIMEZONE_FILES_DIR, TZDATA_PATH, 1);
}
#endif
}