diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-04-06 07:09:56 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-04-06 07:09:56 +0000 |
commit | f73c579d5531540775dd4ac10af305fb5206790b (patch) | |
tree | c84064fb40b44f049e500ce25b036c389793a0c7 /wiretap/file_wrappers.c | |
parent | 7fa6d929cf2dc248fa35259ce8094b7b906b2022 (diff) |
From Jakub Zawadzki:
file-wrappers.[ch] is used only for reading files, and mode is always
"rb".
Attached patch removes 'mode' argument from file_open() & filed_open().
svn path=/trunk/; revision=36493
Diffstat (limited to 'wiretap/file_wrappers.c')
-rw-r--r-- | wiretap/file_wrappers.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/wiretap/file_wrappers.c b/wiretap/file_wrappers.c index ccd8209532..b8682ff205 100644 --- a/wiretap/file_wrappers.c +++ b/wiretap/file_wrappers.c @@ -127,41 +127,22 @@ #ifdef HAVE_LIBZ FILE_T -file_open(const char *path, const char *mode) +file_open(const char *path) { int fd; FILE_T ft; int oflag; - if (*mode == 'r') { - if (strchr(mode + 1, '+') != NULL) - oflag = O_RDWR; - else - oflag = O_RDONLY; - } else if (*mode == 'w') { - if (strchr(mode + 1, '+') != NULL) - oflag = O_RDWR|O_CREAT|O_TRUNC; - else - oflag = O_RDONLY|O_CREAT|O_TRUNC; - } else if (*mode == 'a') { - if (strchr(mode + 1, '+') != NULL) - oflag = O_RDWR|O_APPEND; - else - oflag = O_RDONLY|O_APPEND; - } else { - errno = EINVAL; - return NULL; - } + oflag = O_RDONLY; #ifdef _WIN32 - if (strchr(mode + 1, 'b') != NULL) - oflag |= O_BINARY; + oflag |= O_BINARY; #endif /* open file and do correct filename conversions */ if ((fd = ws_open(path, oflag, 0666)) == -1) return NULL; /* open zlib file handle */ - ft = gzdopen(fd, mode); + ft = gzdopen(fd, "rb"); if (ft == NULL) { ws_close(fd); return NULL; |