mirror of https://git.tukaani.org/xz.git
xz: Add --single-stream.
This can be useful when there is garbage after the compressed stream (.xz, .lzma, or raw stream). Man page wasn't updated yet.
This commit is contained in:
parent
96f94bc925
commit
57597d42ca
|
@ -68,6 +68,7 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
OPT_LZMA1,
|
OPT_LZMA1,
|
||||||
OPT_LZMA2,
|
OPT_LZMA2,
|
||||||
|
|
||||||
|
OPT_SINGLE_STREAM,
|
||||||
OPT_NO_SPARSE,
|
OPT_NO_SPARSE,
|
||||||
OPT_FILES,
|
OPT_FILES,
|
||||||
OPT_FILES0,
|
OPT_FILES0,
|
||||||
|
@ -94,6 +95,7 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
{ "force", no_argument, NULL, 'f' },
|
{ "force", no_argument, NULL, 'f' },
|
||||||
{ "stdout", no_argument, NULL, 'c' },
|
{ "stdout", no_argument, NULL, 'c' },
|
||||||
{ "to-stdout", no_argument, NULL, 'c' },
|
{ "to-stdout", no_argument, NULL, 'c' },
|
||||||
|
{ "single-stream", no_argument, NULL, OPT_SINGLE_STREAM },
|
||||||
{ "no-sparse", no_argument, NULL, OPT_NO_SPARSE },
|
{ "no-sparse", no_argument, NULL, OPT_NO_SPARSE },
|
||||||
{ "suffix", required_argument, NULL, 'S' },
|
{ "suffix", required_argument, NULL, 'S' },
|
||||||
// { "recursive", no_argument, NULL, 'r' }, // TODO
|
// { "recursive", no_argument, NULL, 'r' }, // TODO
|
||||||
|
@ -368,6 +370,10 @@ parse_real(args_info *args, int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case OPT_SINGLE_STREAM:
|
||||||
|
opt_single_stream = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case OPT_NO_SPARSE:
|
case OPT_NO_SPARSE:
|
||||||
io_no_sparse();
|
io_no_sparse();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,6 +24,7 @@ enum coder_init_ret {
|
||||||
enum operation_mode opt_mode = MODE_COMPRESS;
|
enum operation_mode opt_mode = MODE_COMPRESS;
|
||||||
enum format_type opt_format = FORMAT_AUTO;
|
enum format_type opt_format = FORMAT_AUTO;
|
||||||
bool opt_auto_adjust = true;
|
bool opt_auto_adjust = true;
|
||||||
|
bool opt_single_stream = false;
|
||||||
|
|
||||||
|
|
||||||
/// Stream used to communicate with liblzma
|
/// Stream used to communicate with liblzma
|
||||||
|
@ -366,8 +367,9 @@ coder_init(file_pair *pair)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const uint32_t flags = LZMA_TELL_UNSUPPORTED_CHECK
|
uint32_t flags = LZMA_TELL_UNSUPPORTED_CHECK;
|
||||||
| LZMA_CONCATENATED;
|
if (!opt_single_stream)
|
||||||
|
flags |= LZMA_CONCATENATED;
|
||||||
|
|
||||||
// We abuse FORMAT_AUTO to indicate unknown file format,
|
// We abuse FORMAT_AUTO to indicate unknown file format,
|
||||||
// for which we may consider passthru mode.
|
// for which we may consider passthru mode.
|
||||||
|
@ -518,6 +520,11 @@ coder_normal(file_pair *pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == LZMA_STREAM_END) {
|
if (ret == LZMA_STREAM_END) {
|
||||||
|
if (opt_single_stream) {
|
||||||
|
success = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Check that there is no trailing garbage.
|
// Check that there is no trailing garbage.
|
||||||
// This is needed for LZMA_Alone and raw
|
// This is needed for LZMA_Alone and raw
|
||||||
// streams.
|
// streams.
|
||||||
|
|
|
@ -41,6 +41,9 @@ extern enum format_type opt_format;
|
||||||
/// they exceed the memory usage limit.
|
/// they exceed the memory usage limit.
|
||||||
extern bool opt_auto_adjust;
|
extern bool opt_auto_adjust;
|
||||||
|
|
||||||
|
/// If true, stop after decoding the first stream.
|
||||||
|
extern bool opt_single_stream;
|
||||||
|
|
||||||
|
|
||||||
/// Set the integrity check type used when compressing
|
/// Set the integrity check type used when compressing
|
||||||
extern void coder_set_check(lzma_check check);
|
extern void coder_set_check(lzma_check check);
|
||||||
|
|
|
@ -1108,7 +1108,10 @@ message_help(bool long_help)
|
||||||
" -f, --force force overwrite of output file and (de)compress links\n"
|
" -f, --force force overwrite of output file and (de)compress links\n"
|
||||||
" -c, --stdout write to standard output and don't delete input files"));
|
" -c, --stdout write to standard output and don't delete input files"));
|
||||||
|
|
||||||
if (long_help)
|
if (long_help) {
|
||||||
|
puts(_(
|
||||||
|
" --single-stream decompress only the first stream, and silently\n"
|
||||||
|
" ignore possible remaining input data"));
|
||||||
puts(_(
|
puts(_(
|
||||||
" --no-sparse do not create sparse files when decompressing\n"
|
" --no-sparse do not create sparse files when decompressing\n"
|
||||||
" -S, --suffix=.SUF use the suffix `.SUF' on compressed files\n"
|
" -S, --suffix=.SUF use the suffix `.SUF' on compressed files\n"
|
||||||
|
@ -1116,6 +1119,7 @@ message_help(bool long_help)
|
||||||
" omitted, filenames are read from the standard input;\n"
|
" omitted, filenames are read from the standard input;\n"
|
||||||
" filenames must be terminated with the newline character\n"
|
" filenames must be terminated with the newline character\n"
|
||||||
" --files0[=FILE] like --files but use the null character as terminator"));
|
" --files0[=FILE] like --files but use the null character as terminator"));
|
||||||
|
}
|
||||||
|
|
||||||
if (long_help) {
|
if (long_help) {
|
||||||
puts(_("\n Basic file format and compression options:\n"));
|
puts(_("\n Basic file format and compression options:\n"));
|
||||||
|
|
Loading…
Reference in New Issue