diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-12-28 02:28:44 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-12-28 02:28:44 +0000 |
commit | 0ce60e88585927fbd1fa9091e99da0b4694b6d28 (patch) | |
tree | c21b2ba1494e4d0b9d1aa0805098a416bc7e0453 /lib/libarchive | |
parent | 110ffdeb53f5a023d37d975a2a3df6c30a27f1fa (diff) | |
download | FreeBSD-src-0ce60e88585927fbd1fa9091e99da0b4694b6d28.zip FreeBSD-src-0ce60e88585927fbd1fa9091e99da0b4694b6d28.tar.gz |
Portability: Set the file descriptor to binary mode on Win32
Diffstat (limited to 'lib/libarchive')
-rw-r--r-- | lib/libarchive/archive_read_open_file.c | 7 | ||||
-rw-r--r-- | lib/libarchive/archive_read_open_filename.c | 6 | ||||
-rw-r--r-- | lib/libarchive/archive_write_open_fd.c | 9 |
3 files changed, 22 insertions, 0 deletions
diff --git a/lib/libarchive/archive_read_open_file.c b/lib/libarchive/archive_read_open_file.c index 37039e9..1575f94 100644 --- a/lib/libarchive/archive_read_open_file.c +++ b/lib/libarchive/archive_read_open_file.c @@ -35,6 +35,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef HAVE_IO_H +#include <io.h> +#endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -94,6 +97,10 @@ archive_read_open_FILE(struct archive *a, FILE *f) } else mine->can_skip = 0; +#if defined(__CYGWIN__) || defined(_WIN32) + setmode(fileno(mine->f), O_BINARY); +#endif + return (archive_read_open2(a, mine, NULL, file_read, file_skip, file_close)); } diff --git a/lib/libarchive/archive_read_open_filename.c b/lib/libarchive/archive_read_open_filename.c index 64a89b5..ec0bb36 100644 --- a/lib/libarchive/archive_read_open_filename.c +++ b/lib/libarchive/archive_read_open_filename.c @@ -35,6 +35,9 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef HAVE_IO_H +#include <io.h> +#endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -96,6 +99,9 @@ archive_read_open_filename(struct archive *a, const char *filename, */ filename = ""; /* Normalize NULL to "" */ fd = 0; +#if defined(__CYGWIN__) || defined(_WIN32) + setmode(0, O_BINARY); +#endif } else { fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { diff --git a/lib/libarchive/archive_write_open_fd.c b/lib/libarchive/archive_write_open_fd.c index f4cc6ac..b0793a2 100644 --- a/lib/libarchive/archive_write_open_fd.c +++ b/lib/libarchive/archive_write_open_fd.c @@ -32,6 +32,12 @@ __FBSDID("$FreeBSD$"); #ifdef HAVE_ERRNO_H #include <errno.h> #endif +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif +#ifdef HAVE_IO_H +#include <io.h> +#endif #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -64,6 +70,9 @@ archive_write_open_fd(struct archive *a, int fd) return (ARCHIVE_FATAL); } mine->fd = fd; +#if defined(__CYGWIN__) || defined(_WIN32) + setmode(mine->fd, O_BINARY); +#endif return (archive_write_open(a, mine, file_open, file_write, file_close)); } |