1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-13 10:02:38 +00:00

Include O_BINARY in open() calls on platforms that support it.

This commit is contained in:
Tim Kientzle 2008-02-19 06:10:48 +00:00
parent dc4a55fdfc
commit b3fa7a9568
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176405
2 changed files with 13 additions and 3 deletions

View File

@ -47,6 +47,10 @@ __FBSDID("$FreeBSD$");
#include "archive.h"
#ifndef O_BINARY
#define O_BINARY 0
#endif
struct read_file_data {
int fd;
size_t block_size;
@ -113,7 +117,7 @@ file_open(struct archive *a, void *client_data)
return (ARCHIVE_FATAL);
}
if (mine->filename[0] != '\0')
mine->fd = open(mine->filename, O_RDONLY);
mine->fd = open(mine->filename, O_RDONLY | O_BINARY);
else
mine->fd = 0; /* Fake "open" for stdin. */
if (mine->fd < 0) {

View File

@ -50,6 +50,10 @@ __FBSDID("$FreeBSD$");
#include "archive_read_private.h"
#include "archive_string.h"
#ifndef O_BINARY
#define O_BINARY 0
#endif
struct mtree_entry {
struct mtree_entry *next;
char *name;
@ -371,7 +375,8 @@ read_header(struct archive_read *a, struct archive_entry *entry)
* the contents file on disk.)
*/
if (archive_strlen(&mtree->contents_name) > 0) {
mtree->fd = open(mtree->contents_name.s, O_RDONLY);
mtree->fd = open(mtree->contents_name.s,
O_RDONLY | O_BINARY);
if (mtree->fd < 0) {
archive_set_error(&a->archive, errno,
"Can't open content=\"%s\"",
@ -380,7 +385,8 @@ read_header(struct archive_read *a, struct archive_entry *entry)
}
} else {
/* If the specified path opens, use it. */
mtree->fd = open(mtree->current_dir.s, O_RDONLY);
mtree->fd = open(mtree->current_dir.s,
O_RDONLY | O_BINARY);
/* But don't fail if it's not there. */
}