diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-01 12:24:23 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2011-05-01 12:24:23 +0300 |
commit | 7a480e485938884ef3021b48c3b0b9f9699dc9b6 (patch) | |
tree | 21d5755f218c14d35905a516a7ff07dd46872254 /src/xz/file_io.c | |
parent | xz: Print the maximum number of worker threads in xz -vv. (diff) | |
download | xz-7a480e485938884ef3021b48c3b0b9f9699dc9b6.tar.xz |
xz: Fix input file position when --single-stream is used.
Now the following works as you would expect:
echo foo | xz > foo.xz
echo bar | xz >> foo.xz
( xz -dc --single-stream ; xz -dc --single-stream ) < foo.xz
Note that it doesn't work if the input is not seekable
or if there is Stream Padding between the concatenated
.xz Streams.
Diffstat (limited to 'src/xz/file_io.c')
-rw-r--r-- | src/xz/file_io.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/xz/file_io.c b/src/xz/file_io.c index 370b61b7..f9807a69 100644 --- a/src/xz/file_io.c +++ b/src/xz/file_io.c @@ -840,6 +840,21 @@ io_close(file_pair *pair, bool success) } +extern void +io_fix_src_pos(file_pair *pair, size_t rewind_size) +{ + assert(rewind_size <= IO_BUFFER_SIZE); + + if (rewind_size > 0) { + // This doesn't need to work on unseekable file descriptors, + // so just ignore possible errors. + (void)lseek(pair->src_fd, -(off_t)(rewind_size), SEEK_CUR); + } + + return; +} + + extern size_t io_read(file_pair *pair, io_buf *buf_union, size_t size) { |