mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Portability: Set the file descriptor to binary mode on Win32
This commit is contained in:
parent
c0840e91d3
commit
2866e9d5d0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=201093
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue