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.
diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp
index acb9022..0f3c795 100644
--- a/icu4c/source/common/putil.cpp
+++ b/icu4c/source/common/putil.cpp
@@ -1459,6 +1459,11 @@
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 @@
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);
}