1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Fix file_io.c on DOS-like systems.

The problem was introduced when adding sparse file
support in 465d1b0d65.

Thanks to Charles Wilson.
This commit is contained in:
Lasse Collin 2009-12-07 21:46:53 +02:00
parent 0696f5d268
commit 7b76a3e233

View file

@ -40,9 +40,11 @@ static bool warn_fchown;
/// If true, try to create sparse files when decompressing. /// If true, try to create sparse files when decompressing.
static bool try_sparse = true; static bool try_sparse = true;
#ifndef TUKLIB_DOSLIKE
/// File status flags of standard output. This is used by io_open_dest() /// File status flags of standard output. This is used by io_open_dest()
/// and io_close_dest(). /// and io_close_dest().
static int stdout_flags = 0; static int stdout_flags = 0;
#endif
static bool io_write_buf(file_pair *pair, const uint8_t *buf, size_t size); static bool io_write_buf(file_pair *pair, const uint8_t *buf, size_t size);
@ -633,6 +635,7 @@ io_open_dest(file_pair *pair)
static int static int
io_close_dest(file_pair *pair, bool success) io_close_dest(file_pair *pair, bool success)
{ {
#ifndef TUKLIB_DOSLIKE
// If io_open_dest() has disabled O_APPEND, restore it here. // If io_open_dest() has disabled O_APPEND, restore it here.
if (stdout_flags != 0) { if (stdout_flags != 0) {
assert(pair->dest_fd == STDOUT_FILENO); assert(pair->dest_fd == STDOUT_FILENO);
@ -647,6 +650,7 @@ io_close_dest(file_pair *pair, bool success)
return -1; return -1;
} }
} }
#endif
if (pair->dest_fd == -1 || pair->dest_fd == STDOUT_FILENO) if (pair->dest_fd == -1 || pair->dest_fd == STDOUT_FILENO)
return 0; return 0;