diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-03-20 14:32:34 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2015-03-20 14:32:34 -0400 |
commit | 123c0bd6a2cf96c2fd17d542f537257b9de8a8b9 (patch) | |
tree | 31dc64255ccfd92740a9f211da03c97bb0f2f741 /src | |
parent | 6d183e68ee226c10eb41576c45fcf584b6e71201 (diff) | |
download | mongo-123c0bd6a2cf96c2fd17d542f537257b9de8a8b9.tar.gz |
Windows wants FILE handles in binary mode, add a mode argument to
fopen(3), and append 'b' to the mode on Windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/conn/conn_api.c | 2 | ||||
-rw-r--r-- | src/include/extern.h | 2 | ||||
-rw-r--r-- | src/os_posix/os_stdio.c | 19 |
3 files changed, 19 insertions, 4 deletions
diff --git a/src/conn/conn_api.c b/src/conn/conn_api.c index 056c009960c..01ad93844dd 100644 --- a/src/conn/conn_api.c +++ b/src/conn/conn_api.c @@ -1388,7 +1388,7 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[]) if (exist) return (0); - WT_RET(__wt_fp_open(session, WT_BASECONFIG_SET, &fp)); + WT_RET(__wt_fp_open(session, WT_BASECONFIG_SET, "w", &fp)); fprintf(fp, "%s\n\n", "# Do not modify this file.\n" diff --git a/src/include/extern.h b/src/include/extern.h index f6c30b14df9..e977ff5c96e 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -485,7 +485,7 @@ extern int __wt_rename(WT_SESSION_IMPL *session, const char *from, const char *t extern int __wt_read( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, size_t len, void *buf); extern int __wt_write(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, size_t len, const void *buf); extern void __wt_sleep(uint64_t seconds, uint64_t micro_seconds); -extern int __wt_fp_open(WT_SESSION_IMPL *session, const char *name, FILE **fpp); +extern int __wt_fp_open(WT_SESSION_IMPL *session, const char *name, const char *mode, FILE **fpp); extern int __wt_fp_close(WT_SESSION_IMPL *session, FILE **fpp); extern uint64_t __wt_strtouq(const char *nptr, char **endptr, int base); extern int __wt_thread_create(WT_SESSION_IMPL *session, wt_thread_t *tidret, void *(*func)(void *), void *arg); diff --git a/src/os_posix/os_stdio.c b/src/os_posix/os_stdio.c index 4c8be28cd8e..62c02babc54 100644 --- a/src/os_posix/os_stdio.c +++ b/src/os_posix/os_stdio.c @@ -13,14 +13,29 @@ * Open a FILE handle. */ int -__wt_fp_open(WT_SESSION_IMPL *session, const char *name, FILE **fpp) +__wt_fp_open(WT_SESSION_IMPL *session, + const char *name, const char *mode, FILE **fpp) { WT_DECL_RET; char *path; WT_RET(__wt_filename(session, name, &path)); - if ((*fpp = fopen(path, "w")) == NULL) +#ifdef _WIN32 + { + char buf[10]; + /* + * Open in binary (untranslated) mode; translations involving + * carriage-return and linefeed characters are suppressed. + */ + (void)snprintf(buf, sizeof(buf), "%s" "b", mode); + + *fpp = fopen(path, buf); + } +#else + *fpp = fopen(path, mode); +#endif + if (*fpp == NULL) ret = __wt_errno(); __wt_free(session, path); |