aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read_open_file.c7
-rw-r--r--lib/libarchive/archive_read_open_filename.c6
-rw-r--r--lib/libarchive/archive_write_open_fd.c9
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 37039e95a111..1575f94ca443 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 64a89b52b3c9..ec0bb369e036 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 f4cc6ac1c54e..b0793a26bc89 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));
}