diff options
Diffstat (limited to 'main.cc')
-rw-r--r-- | main.cc | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -61,6 +61,7 @@ namespace { const char * const program_name = "tarlz"; const char * const program_year = "2019"; const char * invocation_name = 0; +bool dereference = false; void show_help( const long num_online ) @@ -82,7 +83,7 @@ void show_help( const long num_online ) "can be used to recover some of the damaged members.\n" "\nUsage: %s [options] [files]\n", invocation_name ); std::printf( "\nOptions:\n" - " -h, --help display this help and exit\n" + " --help display this help and exit\n" " -V, --version output version information and exit\n" " -A, --concatenate append tar.lz archives to the end of an archive\n" " -B, --data-size=<bytes> set target size of input data blocks [2x8=16 MiB]\n" @@ -90,7 +91,9 @@ void show_help( const long num_online ) " -C, --directory=<dir> change to directory <dir>\n" " -d, --diff find differences between archive and file system\n" " --ignore-ids ignore differences in owner and group IDs\n" + " --exclude=<pattern> exclude files matching a shell pattern\n" " -f, --file=<archive> use archive file <archive>\n" + " -h, --dereference follow symlinks; archive the files they point to\n" " -n, --threads=<n> set number of (de)compression threads [%ld]\n" " -q, --quiet suppress all messages\n" " -r, --append append files to the end of an archive\n" @@ -109,6 +112,7 @@ void show_help( const long num_online ) " --group=<group> use <group> name/ID for files added\n" " --keep-damaged don't delete partially extracted files\n" " --missing-crc exit with error status if missing extended CRC\n" + " --out-slots=<n> number of 1 MiB output packets buffered [64]\n" /* " --permissive allow repeated extended headers and records\n"*/, num_online ); if( verbosity >= 1 ) @@ -217,6 +221,10 @@ void set_group( const char * const arg ) } // end namespace +int hstat( const char * const filename, struct stat * const st ) + { return dereference ? stat( filename, st ) : lstat( filename, st ); } + + int open_instream( const std::string & name ) { const int infd = open( name.c_str(), O_RDONLY | O_BINARY ); @@ -288,8 +296,9 @@ int main( const int argc, const char * const argv[] ) { std::string archive_name; int debug_level = 0; - int num_workers = -1; // start this many worker threads int level = 6; // compression level, < 0 means uncompressed + int num_workers = -1; // start this many worker threads + int out_slots = 64; Program_mode program_mode = m_none; bool ignore_ids = false; bool keep_damaged = false; @@ -301,8 +310,9 @@ int main( const int argc, const char * const argv[] ) { show_error( "Bad library version. At least lzlib 1.0 is required." ); return 1; } - enum { opt_ano = 256, opt_aso, opt_bso, opt_crc, opt_dbg, opt_dso, opt_grp, - opt_id, opt_kd, opt_nso, opt_own, opt_per, opt_sol, opt_un }; + enum { opt_ano = 256, opt_aso, opt_bso, opt_crc, opt_dbg, opt_dso, opt_exc, + opt_grp, opt_hlp, opt_id, opt_kd, opt_nso, opt_out, opt_own, opt_per, + opt_sol, opt_un }; const Arg_parser::Option options[] = { { '0', 0, Arg_parser::no }, @@ -321,7 +331,7 @@ int main( const int argc, const char * const argv[] ) { 'C', "directory", Arg_parser::yes }, { 'd', "diff", Arg_parser::no }, { 'f', "file", Arg_parser::yes }, - { 'h', "help", Arg_parser::no }, + { 'h', "dereference", Arg_parser::no }, { 'H', "format", Arg_parser::yes }, { 'n', "threads", Arg_parser::yes }, { 'q', "quiet", Arg_parser::no }, @@ -335,11 +345,14 @@ int main( const int argc, const char * const argv[] ) { opt_bso, "bsolid", Arg_parser::no }, { opt_dbg, "debug", Arg_parser::yes }, { opt_dso, "dsolid", Arg_parser::no }, + { 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_kd, "keep-damaged", Arg_parser::no }, { opt_crc, "missing-crc", Arg_parser::no }, { opt_nso, "no-solid", Arg_parser::no }, + { opt_out, "out-slots", Arg_parser::yes }, { opt_own, "owner", Arg_parser::yes }, { opt_per, "permissive", Arg_parser::no }, { opt_sol, "solid", Arg_parser::no }, @@ -375,7 +388,7 @@ int main( const int argc, const char * const argv[] ) case 'C': break; // skip chdir case 'd': set_mode( program_mode, m_diff ); break; case 'f': if( sarg != "-" ) archive_name = sarg; break; - case 'h': show_help( num_online ); return 0; + case 'h': dereference = true; break; case 'H': break; // ignore format case 'n': num_workers = getnum( arg, 0, max_workers ); break; case 'q': verbosity = -1; break; @@ -390,10 +403,13 @@ int main( const int argc, const char * const argv[] ) case opt_crc: missing_crc = true; break; case opt_dbg: debug_level = getnum( arg, 0, 3 ); break; case opt_dso: solidity = dsolid; break; + case opt_exc: Exclude::add_pattern( sarg ); break; case opt_grp: set_group( arg ); break; + case opt_hlp: show_help( num_online ); return 0; case opt_id: ignore_ids = true; break; case opt_kd: keep_damaged = true; break; case opt_nso: solidity = no_solid; break; + case opt_out: out_slots = getnum( arg, 1, 1024 ); break; case opt_own: set_owner( arg ); break; case opt_per: permissive = true; break; case opt_sol: solidity = solid; break; @@ -414,7 +430,8 @@ int main( const int argc, const char * const argv[] ) case m_none: show_error( "Missing operation.", 0, true ); return 2; case m_append: case m_create: return encode( archive_name, parser, filenames, level, - num_workers, debug_level, program_mode == m_append ); + num_workers, out_slots, debug_level, + program_mode == m_append, dereference ); case m_concatenate: return concatenate( archive_name, parser, filenames ); case m_diff: case m_extract: |