ICU-20895 ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR

Adds `ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR`, similar to
`ICU_DATA_DIR_PREFIX_ENV_VAR`, that specifies an environment variable
to retrieve and prepend to the ICU time zone data file path.
This commit is contained in:
Andrew Paprocki 2019-11-11 19:46:05 -05:00 committed by Yoshito Umaoka
parent 6ea0fc7713
commit cd41cba82a

View File

@ -1459,6 +1459,11 @@ static void U_CALLCONV TimeZoneDataDirInitFn(UErrorCode &status) {
const char *dir = "";
#if defined(ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR)
char timezonefilesdir_path_buffer[PATH_MAX];
const char *prefix = getenv(ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR);
#endif
#if U_PLATFORM_HAS_WINUWP_API == 1
// The UWP version does not support the environment variable setting.
@ -1485,6 +1490,13 @@ static void U_CALLCONV TimeZoneDataDirInitFn(UErrorCode &status) {
dir = "";
}
#if defined(ICU_TIMEZONE_FILES_DIR_PREFIX_ENV_VAR)
if (prefix != NULL) {
snprintf(timezonefilesdir_path_buffer, PATH_MAX, "%s%s", prefix, dir);
dir = timezonefilesdir_path_buffer;
}
#endif
setTimeZoneFilesDir(dir, status);
}