summaryrefslogtreecommitdiffstats
path: root/create_lz.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-24 01:57:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-09-24 01:57:58 +0000
commitd35175c9e68a3ad252bfa22d266b8311df99a718 (patch)
tree0ed6c60ad70805dbda31e05d43ee1b967c478938 /create_lz.cc
parentReleasing debian version 0.22-4. (diff)
downloadtarlz-d35175c9e68a3ad252bfa22d266b8311df99a718.tar.xz
tarlz-d35175c9e68a3ad252bfa22d266b8311df99a718.zip
Merging upstream version 0.23.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'create_lz.cc')
-rw-r--r--create_lz.cc21
1 files changed, 10 insertions, 11 deletions
diff --git a/create_lz.cc b/create_lz.cc
index 67a6f7a..1acaf23 100644
--- a/create_lz.cc
+++ b/create_lz.cc
@@ -267,6 +267,7 @@ int add_member_lz( const char * const filename, const struct stat *,
{ show_error( mem_msg ); if( extended ) delete extended; return 1; }
if( !fill_headers( filename, *extended, header, file_size, flag ) )
{ delete[] header; delete extended; return 0; }
+ print_removed_prefix( extended->removed_prefix );
if( gcl_opts->solidity == bsolid &&
block_is_full( extended->full_size(), file_size, gcl_opts->data_size,
@@ -304,8 +305,7 @@ extern "C" void * grouper( void * arg )
const std::string & arg = cl_opts.parser.argument( i );
const char * filename = arg.c_str();
if( code == 'C' && chdir( filename ) != 0 )
- { show_file_error( filename, "Error changing working directory", errno );
- exit_fail_mt(); }
+ { show_file_error( filename, chdir_msg, errno ); exit_fail_mt(); }
if( code ) continue; // skip options
if( cl_opts.parser.argument( i ).empty() ) continue; // skip empty names
std::string deslashed; // arg without trailing slashes
@@ -448,7 +448,7 @@ extern "C" void * cworker( void * arg )
{
const long long ebsize = ipacket->extended->format_block( rbuf );
if( ebsize < 0 )
- { show_error( "Error formatting extended records." ); exit_fail_mt(); }
+ { show_error( ( ebsize == -2 ) ? mem_msg2 : eferec_msg ); exit_fail_mt(); }
/* Limit the size of the extended block to INT_MAX - 1 so that it can
be fed to lzlib as one buffer. */
if( ebsize >= INT_MAX )
@@ -488,8 +488,7 @@ extern "C" void * cworker( void * arg )
loop_encode( buf, size, data, opos, courier, encoder, worker_id );
}
if( close( infd ) != 0 )
- { show_file_error( filename, "Error closing file", errno );
- exit_fail_mt(); }
+ { show_file_error( filename, eclosf_msg, errno ); exit_fail_mt(); }
}
if( gcl_opts->warn_newer && archive_attrs.is_newer( filename ) )
{ show_file_error( filename, "File is newer than the archive." );
@@ -525,13 +524,14 @@ void muxer( Packet_courier & courier, const int outfd )
// init the courier, then start the grouper and the workers and call the muxer
int encode_lz( const Cl_options & cl_opts, const char * const archive_namep,
- const int dictionary_size, const int match_len_limit,
const int outfd )
{
const int in_slots = 65536; // max small files (<=512B) in 64 MiB
const int num_workers = cl_opts.num_workers;
const int total_in_slots = ( INT_MAX / num_workers >= in_slots ) ?
num_workers * in_slots : INT_MAX;
+ const int dictionary_size = option_mapping[cl_opts.level].dictionary_size;
+ const int match_len_limit = option_mapping[cl_opts.level].match_len_limit;
gcl_opts = &cl_opts;
/* If an error happens after any threads have been started, exit must be
@@ -546,7 +546,7 @@ int encode_lz( const Cl_options & cl_opts, const char * const archive_namep,
pthread_t grouper_thread;
int errcode = pthread_create( &grouper_thread, 0, grouper, &grouper_arg );
if( errcode )
- { show_error( "Can't create grouper thread", errcode ); exit_fail_mt(); }
+ { show_error( "Can't create grouper thread", errcode ); return 1; }
Worker_arg * worker_args = new( std::nothrow ) Worker_arg[num_workers];
pthread_t * worker_threads = new( std::nothrow ) pthread_t[num_workers];
@@ -579,11 +579,10 @@ int encode_lz( const Cl_options & cl_opts, const char * const archive_namep,
{ show_error( "Can't join grouper thread", errcode ); exit_fail_mt(); }
// write End-Of-Archive records
- int retval = !write_eof_records( outfd, true );
+ int retval = !write_eoa_records( outfd, true );
- if( close( outfd ) != 0 && !retval )
- { show_file_error( archive_namep, "Error closing archive", errno );
- retval = 1; }
+ if( close( outfd ) != 0 && retval == 0 )
+ { show_file_error( archive_namep, eclosa_msg, errno ); retval = 1; }
if( cl_opts.debug_level & 1 )
std::fprintf( stderr,