diff options
author | Susan LoVerso <sue@wiredtiger.com> | 2015-03-24 11:35:24 -0400 |
---|---|---|
committer | Susan LoVerso <sue@wiredtiger.com> | 2015-03-24 11:35:24 -0400 |
commit | 1df7f45ff9834c5eeb77b979339c3529df9f620f (patch) | |
tree | bf60bccf8bae4935a5bb9c42c0748273967881e4 /src/os_posix | |
parent | 2a6f8372f8a116bb515a380a80498853f7f3e97e (diff) | |
download | mongo-1df7f45ff9834c5eeb77b979339c3529df9f620f.tar.gz |
Add a single set of fhandle flags for open and close. #1785
Diffstat (limited to 'src/os_posix')
-rw-r--r-- | src/os_posix/os_stdio.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/os_posix/os_stdio.c b/src/os_posix/os_stdio.c index 071bdd9fd33..0f2355aa70d 100644 --- a/src/os_posix/os_stdio.c +++ b/src/os_posix/os_stdio.c @@ -14,10 +14,10 @@ */ int __wt_fopen(WT_SESSION_IMPL *session, - const char *name, const char *mode, u_int flags, FILE **fpp) + const char *name, WT_FHANDLE_MODE mode_flag, u_int flags, FILE **fpp) { WT_DECL_RET; - const char *path; + const char *mode, *path; char *pathbuf; WT_RET(__wt_verbose(session, WT_VERB_FILEOPS, "%s: fopen", name)); @@ -30,20 +30,18 @@ __wt_fopen(WT_SESSION_IMPL *session, path = pathbuf; } -#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); + switch (mode_flag) { + case WT_FHANDLE_APPEND: + mode = WT_FOPEN_APPEND; + break; + case WT_FHANDLE_READ: + mode = WT_FOPEN_READ; + break; + case WT_FHANDLE_WRITE: + mode = WT_FOPEN_WRITE; + break; } -#else *fpp = fopen(path, mode); -#endif if (*fpp == NULL) ret = __wt_errno(); @@ -105,7 +103,7 @@ __wt_fflush(WT_SESSION_IMPL *session, FILE *fp) * Close a FILE handle. */ int -__wt_fclose(WT_SESSION_IMPL *session, FILE **fpp, int iswrite) +__wt_fclose(WT_SESSION_IMPL *session, FILE **fpp, WT_FHANDLE_MODE mode_flag) { FILE *fp; WT_DECL_RET; @@ -120,7 +118,7 @@ __wt_fclose(WT_SESSION_IMPL *session, FILE **fpp, int iswrite) * If the handle was opened for writing, flush the file to the backing * OS buffers, then flush the OS buffers to the backing disk. */ - if (iswrite) { + if (mode_flag == WT_FHANDLE_APPEND || mode_flag == WT_FHANDLE_WRITE) { ret = __wt_fflush(session, fp); if (fsync(fileno(fp)) != 0) WT_TRET(__wt_errno()); |