Adding upstream version 0.25.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
4f5d0de2b2
commit
8853aa3bf2
33 changed files with 317 additions and 280 deletions
57
main.cc
57
main.cc
|
@ -1,5 +1,5 @@
|
|||
/* Tarlz - Archiver with multimember lzip compression
|
||||
Copyright (C) 2013-2023 Antonio Diaz Diaz.
|
||||
Copyright (C) 2013-2024 Antonio Diaz Diaz.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
/*
|
||||
Exit status: 0 for a normal exit, 1 for environmental problems
|
||||
(file not found, files differ, invalid command line options, I/O errors,
|
||||
(file not found, files differ, invalid command-line options, I/O errors,
|
||||
etc), 2 to indicate a corrupt or invalid input file, 3 for an internal
|
||||
consistency error (e.g., bug) which caused tarlz to panic.
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ const char * const program_name = "tarlz";
|
|||
|
||||
namespace {
|
||||
|
||||
const char * const program_year = "2023";
|
||||
const char * const program_year = "2024";
|
||||
const char * invocation_name = program_name; // default value
|
||||
|
||||
|
||||
|
@ -65,12 +65,12 @@ void show_help( const long num_online )
|
|||
std::printf( "Tarlz is a massively parallel (multi-threaded) combined implementation of\n"
|
||||
"the tar archiver and the lzip compressor. Tarlz uses the compression library\n"
|
||||
"lzlib.\n"
|
||||
"\nTarlz creates, lists, and extracts archives in a simplified and safer\n"
|
||||
"variant of the POSIX pax format compressed in lzip format, keeping the\n"
|
||||
"alignment between tar members and lzip members. The resulting multimember\n"
|
||||
"tar.lz archive is fully backward compatible with standard tar tools like GNU\n"
|
||||
"tar, which treat it like any other tar.lz archive. Tarlz can append files to\n"
|
||||
"the end of such compressed archives.\n"
|
||||
"\nTarlz creates tar archives using a simplified and safer variant of the POSIX\n"
|
||||
"pax format compressed in lzip format, keeping the alignment between tar\n"
|
||||
"members and lzip members. The resulting multimember tar.lz archive is\n"
|
||||
"backward compatible with standard tar tools like GNU tar, which treat it\n"
|
||||
"like any other tar.lz archive. Tarlz can append files to the end of such\n"
|
||||
"compressed archives.\n"
|
||||
"\nKeeping the alignment between tar members and lzip members has two\n"
|
||||
"advantages. It adds an indexed lzip layer on top of the tar archive, making\n"
|
||||
"it possible to decode the archive safely in parallel. It also minimizes the\n"
|
||||
|
@ -116,6 +116,7 @@ void show_help( const long num_online )
|
|||
" --group=<group> use <group> name/ID for files added to archive\n"
|
||||
" --exclude=<pattern> exclude files matching a shell pattern\n"
|
||||
" --ignore-ids ignore differences in owner and group IDs\n"
|
||||
" --ignore-metadata compare only file size and file content\n"
|
||||
" --ignore-overflow ignore mtime overflow differences on 32-bit\n"
|
||||
" --keep-damaged don't delete partially extracted files\n"
|
||||
" --missing-crc exit with error status if missing extended CRC\n"
|
||||
|
@ -131,7 +132,7 @@ void show_help( const long num_online )
|
|||
std::printf( "\nIf no archive is specified, tarlz tries to read it from standard input or\n"
|
||||
"write it to standard output.\n"
|
||||
"\nExit status: 0 for a normal exit, 1 for environmental problems\n"
|
||||
"(file not found, files differ, invalid command line options, I/O errors,\n"
|
||||
"(file not found, files differ, invalid command-line options, I/O errors,\n"
|
||||
"etc), 2 to indicate a corrupt or invalid input file, 3 for an internal\n"
|
||||
"consistency error (e.g., bug) which caused tarlz to panic.\n"
|
||||
"\nReport bugs to lzip-bug@nongnu.org\n"
|
||||
|
@ -211,9 +212,9 @@ int check_lib()
|
|||
// separate numbers of 5 or more digits in groups of 3 digits using '_'
|
||||
const char * format_num3( long long num )
|
||||
{
|
||||
enum { buffers = 8, bufsize = 4 * sizeof num, n = 10 };
|
||||
const char * const si_prefix = "kMGTPEZYRQ";
|
||||
const char * const binary_prefix = "KMGTPEZYRQ";
|
||||
enum { buffers = 8, bufsize = 4 * sizeof num };
|
||||
static char buffer[buffers][bufsize]; // circle of static buffers for printf
|
||||
static int current = 0;
|
||||
|
||||
|
@ -221,14 +222,17 @@ const char * format_num3( long long num )
|
|||
char * p = buf + bufsize - 1; // fill the buffer backwards
|
||||
*p = 0; // terminator
|
||||
const bool negative = num < 0;
|
||||
char prefix = 0; // try binary first, then si
|
||||
for( int i = 0; i < 8 && num != 0 && ( num / 1024 ) * 1024 == num; ++i )
|
||||
{ num /= 1024; prefix = binary_prefix[i]; }
|
||||
if( prefix ) *(--p) = 'i';
|
||||
else
|
||||
for( int i = 0; i < 8 && num != 0 && ( num / 1000 ) * 1000 == num; ++i )
|
||||
{ num /= 1000; prefix = si_prefix[i]; }
|
||||
if( prefix ) *(--p) = prefix;
|
||||
if( num > 1024 || num < -1024 )
|
||||
{
|
||||
char prefix = 0; // try binary first, then si
|
||||
for( int i = 0; i < n && num != 0 && num % 1024 == 0; ++i )
|
||||
{ num /= 1024; prefix = binary_prefix[i]; }
|
||||
if( prefix ) *(--p) = 'i';
|
||||
else
|
||||
for( int i = 0; i < n && num != 0 && num % 1000 == 0; ++i )
|
||||
{ num /= 1000; prefix = si_prefix[i]; }
|
||||
if( prefix ) *(--p) = prefix;
|
||||
}
|
||||
const bool split = num >= 10000 || num <= -10000;
|
||||
|
||||
for( int i = 0; ; )
|
||||
|
@ -251,8 +255,7 @@ void show_option_error( const char * const arg, const char * const msg,
|
|||
}
|
||||
|
||||
|
||||
// Recognized formats: <num>[QRYZEPTGM][i], <num>k, <num>Ki
|
||||
//
|
||||
// Recognized formats: <num>k, <num>Ki, <num>[MGTPEZYRQ][i]
|
||||
long long getnum( const char * const arg, const char * const option_name,
|
||||
const long long llimit = LLONG_MIN,
|
||||
const long long ulimit = LLONG_MAX )
|
||||
|
@ -524,8 +527,8 @@ int main( const int argc, const char * const argv[] )
|
|||
if( argc > 0 ) invocation_name = argv[0];
|
||||
|
||||
enum { opt_ano = 256, opt_aso, opt_bso, opt_chk, opt_crc, opt_dbg, opt_del,
|
||||
opt_dso, opt_exc, opt_grp, opt_hlp, opt_id, opt_kd, opt_mti, opt_nso,
|
||||
opt_ofl, opt_out, opt_own, opt_per, opt_sol, opt_un, opt_wn };
|
||||
opt_dso, opt_exc, opt_grp, opt_hlp, opt_iid, opt_imd, opt_kd, opt_mti,
|
||||
opt_nso, opt_ofl, opt_out, opt_own, opt_per, opt_sol, opt_un, opt_wn };
|
||||
const Arg_parser::Option options[] =
|
||||
{
|
||||
{ '0', 0, Arg_parser::no },
|
||||
|
@ -566,7 +569,8 @@ int main( const int argc, const char * const argv[] )
|
|||
{ opt_exc, "exclude", Arg_parser::yes },
|
||||
{ opt_grp, "group", Arg_parser::yes },
|
||||
{ opt_hlp, "help", Arg_parser::no },
|
||||
{ opt_id, "ignore-ids", Arg_parser::no },
|
||||
{ opt_iid, "ignore-ids", Arg_parser::no },
|
||||
{ opt_imd, "ignore-metadata", Arg_parser::no },
|
||||
{ opt_kd, "keep-damaged", Arg_parser::no },
|
||||
{ opt_crc, "missing-crc", Arg_parser::no },
|
||||
{ opt_mti, "mtime", Arg_parser::yes },
|
||||
|
@ -642,7 +646,8 @@ int main( const int argc, const char * const argv[] )
|
|||
case opt_exc: Exclude::add_pattern( sarg ); break;
|
||||
case opt_grp: cl_opts.gid = parse_group( arg, pn ); break;
|
||||
case opt_hlp: show_help( num_online ); return 0;
|
||||
case opt_id: cl_opts.ignore_ids = true; break;
|
||||
case opt_iid: cl_opts.ignore_ids = true; break;
|
||||
case opt_imd: cl_opts.ignore_metadata = true; break;
|
||||
case opt_kd: cl_opts.keep_damaged = true; break;
|
||||
case opt_mti: cl_opts.mtime = parse_mtime( arg, pn );
|
||||
cl_opts.mtime_set = true; break;
|
||||
|
@ -654,7 +659,7 @@ int main( const int argc, const char * const argv[] )
|
|||
case opt_sol: cl_opts.solidity = solid; break;
|
||||
case opt_un: cl_opts.set_level( -1 ); break;
|
||||
case opt_wn: cl_opts.warn_newer = true; break;
|
||||
default : internal_error( "uncaught option" );
|
||||
default: internal_error( "uncaught option." );
|
||||
}
|
||||
} // end process options
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue