diff options
Diffstat (limited to 'list_lz.cc')
-rw-r--r-- | list_lz.cc | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -32,7 +32,6 @@ #include <lzlib.h> #include "arg_parser.h" -#include "lzip.h" #include "lzip_index.h" #include "tarlz.h" @@ -355,8 +354,8 @@ int list_member_lz( LZ_Decoder * const decoder, const int infd, Resizable_buffer & rbuf, const long member_id, const int worker_id, const char ** msg, const bool skip ) { - unsigned long long rest = extended.size; - const int rem = extended.size % header_size; + unsigned long long rest = extended.file_size(); + const int rem = rest % header_size; const int padding = rem ? header_size - rem : 0; const long long data_rest = mdata_end - ( data_pos + rest + padding ); bool master = false; @@ -527,7 +526,7 @@ extern "C" void * dworker_l( void * arg ) ret = 2; } else ret = parse_records_lz( decoder, infd, file_pos, member_end, cdata_size, data_pos, extended, header, &msg, permissive ); - if( ret == 0 && !extended.crc_present && missing_crc ) + if( ret == 0 && !extended.crc_present() && missing_crc ) { msg = "Missing CRC in extended records."; ret = 2; } if( ret != 0 ) { @@ -549,16 +548,20 @@ extern "C" void * dworker_l( void * arg ) } prev_extended = false; - if( extended.linkpath.empty() ) // copy linkpath from ustar header + if( extended.linkpath().empty() ) // copy linkpath from ustar header { - for( int i = 0; i < linkname_l && header[linkname_o+i]; ++i ) - extended.linkpath += header[linkname_o+i]; - while( extended.linkpath.size() > 1 && // trailing '/' - extended.linkpath[extended.linkpath.size()-1] == '/' ) - extended.linkpath.resize( extended.linkpath.size() - 1 ); + int len = 0; + while( len < linkname_l && header[linkname_o+len] ) ++len; + while( len > 1 && header[linkname_o+len-1] == '/' ) --len; // trailing '/' + if( len > 0 ) + { + const uint8_t c = header[linkname_o+len]; header[linkname_o+len] = 0; + extended.linkpath( (const char *)header + linkname_o ); + header[linkname_o+len] = c; + } } - if( extended.path.empty() ) // copy path from ustar header + if( extended.path().empty() ) // copy path from ustar header { char stored_name[prefix_l+1+name_l+1]; int len = 0; @@ -569,9 +572,9 @@ extern "C" void * dworker_l( void * arg ) { stored_name[len] = header[name_o+i]; ++len; } while( len > 0 && stored_name[len-1] == '/' ) --len; // trailing '/' stored_name[len] = 0; - extended.path = remove_leading_slash( stored_name ); + extended.path( remove_leading_slash( stored_name ) ); } - const char * const filename = extended.path.c_str(); + const char * const filename = extended.path().c_str(); bool skip = filenames > 0; if( skip ) @@ -585,9 +588,9 @@ extern "C" void * dworker_l( void * arg ) { skip = false; name_pending[i] = false; break; } } - if( extended.size == 0 && + if( extended.file_size() == 0 && ( typeflag == tf_regular || typeflag == tf_hiperf ) ) - extended.size = parse_octal( header + size_o, size_l ); + extended.file_size( parse_octal( header + size_o, size_l ) ); retval = list_member_lz( decoder, infd, file_pos, member_end, cdata_size, data_pos, mdata_end, courier, @@ -643,7 +646,7 @@ int list_lz( const Arg_parser & parser, std::vector< char > & name_pending, const int debug_level, const int infd, const int num_workers, const bool missing_crc, const bool permissive ) { - const int out_slots = 100; + const int out_slots = 65536; // max small files (<=512B) in 64 MiB Packet_courier courier( num_workers, out_slots ); Worker_arg * worker_args = new( std::nothrow ) Worker_arg[num_workers]; |