diff options
author | James Wahlin <james@mongodb.com> | 2020-05-29 11:06:32 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-12 14:22:54 +0000 |
commit | 56ef6a8f586e58f2d23911226c7880a7b678e0af (patch) | |
tree | b754496882ff868a2a1e981d78f35f90333518bf /src/third_party | |
parent | 4bd561c80d376130cf851fed23d1261ac36179fc (diff) | |
download | mongo-56ef6a8f586e58f2d23911226c7880a7b678e0af.tar.gz |
SERVER-44273 Fix timeZoneInfo file load on Windows
Diffstat (limited to 'src/third_party')
-rw-r--r-- | src/third_party/timelib-2018.01/parse_zoneinfo.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/third_party/timelib-2018.01/parse_zoneinfo.c b/src/third_party/timelib-2018.01/parse_zoneinfo.c index 875d7564074..977f5abf578 100644 --- a/src/third_party/timelib-2018.01/parse_zoneinfo.c +++ b/src/third_party/timelib-2018.01/parse_zoneinfo.c @@ -52,6 +52,8 @@ # define TIMELIB_DIR_SEPARATOR "/" #endif +#define TIMELIB_NAME_SEPARATOR "/" + /* Filter out some non-tzdata files and the posix/right databases, if * present. */ static int index_filter(const struct dirent *ent) @@ -123,7 +125,12 @@ static char *read_tzfile(const char *directory, const char *timezone, size_t *le return NULL; } + /* O_BINARY is required to properly read the file on windows */ +#ifdef _WIN32 + fd = open(fname, O_RDONLY | O_BINARY); +#else fd = open(fname, O_RDONLY); +#endif free(fname); if (fd == -1) { @@ -257,7 +264,7 @@ static int create_zone_index(const char *directory, timelib_tzdb *db) struct stat st; const char *leaf = ents[count - 1]->d_name; - snprintf(name, sizeof(name), "%s%s%s%s%s", directory, TIMELIB_DIR_SEPARATOR, top, TIMELIB_DIR_SEPARATOR, leaf); + snprintf(name, sizeof(name), "%s%s%s%s%s", directory, TIMELIB_NAME_SEPARATOR, top, TIMELIB_NAME_SEPARATOR, leaf); if (strlen(name) && stat(name, &st) == 0) { /* Name, relative to the zoneinfo prefix. */ @@ -267,7 +274,7 @@ static int create_zone_index(const char *directory, timelib_tzdb *db) root++; } - snprintf(name, sizeof(name), "%s%s%s", root, *root ? TIMELIB_DIR_SEPARATOR : "", leaf); + snprintf(name, sizeof(name), "%s%s%s", root, *root ? TIMELIB_NAME_SEPARATOR : "", leaf); if (S_ISDIR(st.st_mode)) { if (dirstack_top == dirstack_size) { |