From 321b4b38cb22eb640619cebcb1230c604b2e9297 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 24 Sep 2022 03:57:46 +0200 Subject: Adding upstream version 0.23. Signed-off-by: Daniel Baumann --- create_lz.cc | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'create_lz.cc') 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, -- cgit v1.2.3