aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-30 04:18:13 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-30 04:18:13 +0200
commit6948f210ed443f8153e0ba751e77bec8a0c6c8d4 (patch)
tree134443f225a788cbb4fda7b4713ee2bc535fb126 /archival
parentfb6c76cb6eaade5693b7e99c33846c902689f1db (diff)
downloadbusybox-6948f210ed443f8153e0ba751e77bec8a0c6c8d4.tar.gz
*: teach tar et. al. to understand .xz by heart
function old new delta unpack_xz_stream - 4126 +4126 setup_unzip_on_fd 80 150 +70 open_zipped 113 131 +18 unpack_unxz 5 12 +7 send_tree 360 353 -7 unpack_xz_stream_stdin 3953 - -3953 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 3/1 up/down: 4221/-3960) Total: 261 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival')
-rw-r--r--archival/bbunzip.c2
-rw-r--r--archival/libunarchive/decompress_unxz.c9
2 files changed, 6 insertions, 5 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index 1c8d0ab55..86adb6e24 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -374,7 +374,7 @@ char* make_new_name_unxz(char *filename)
static
IF_DESKTOP(long long) int unpack_unxz(unpack_info_t *info UNUSED_PARAM)
{
- return unpack_xz_stream_stdin();
+ return unpack_xz_stream(STDIN_FILENO, STDOUT_FILENO);
}
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unxz_main(int argc UNUSED_PARAM, char **argv)
diff --git a/archival/libunarchive/decompress_unxz.c b/archival/libunarchive/decompress_unxz.c
index 0ae789160..9edc2461a 100644
--- a/archival/libunarchive/decompress_unxz.c
+++ b/archival/libunarchive/decompress_unxz.c
@@ -3,7 +3,7 @@
* by Lasse Collin <lasse.collin@tukaani.org>
* and Igor Pavlov <http://7-zip.org/>
*
- * See README file in unxzbz/ directory for more information.
+ * See README file in unxz/ directory for more information.
*
* This file is:
* Copyright (C) 2010 Denys Vlasenko <vda.linux@googlemail.com>
@@ -48,7 +48,7 @@ static uint32_t xz_crc32(uint32_t *crc32_table,
#include "unxz/xz_stream.h"
IF_DESKTOP(long long) int FAST_FUNC
-unpack_xz_stream_stdin(void)
+unpack_xz_stream(int src_fd, int dst_fd)
{
struct xz_buf iobuf;
struct xz_dec *state;
@@ -79,7 +79,7 @@ unpack_xz_stream_stdin(void)
iobuf.in_pos = 0;
rd = IN_SIZE - insz;
if (rd) {
- rd = safe_read(STDIN_FILENO, membuf + insz, rd);
+ rd = safe_read(src_fd, membuf + insz, rd);
if (rd < 0) {
bb_error_msg("read error");
total = -1;
@@ -94,10 +94,11 @@ unpack_xz_stream_stdin(void)
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, r);
outpos = iobuf.out_pos;
if (outpos) {
- xwrite(STDOUT_FILENO, iobuf.out, outpos);
+ xwrite(dst_fd, iobuf.out, outpos);
IF_DESKTOP(total += outpos;)
}
if (r == XZ_STREAM_END
+ /* this happens even with well-formed files: */
|| (r == XZ_BUF_ERROR && insz == 0 && outpos == 0)
) {
break;