summaryrefslogtreecommitdiffstats
path: root/range_dec.cc
diff options
context:
space:
mode:
Diffstat (limited to 'range_dec.cc')
-rw-r--r--range_dec.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/range_dec.cc b/range_dec.cc
index d056271..51eeb47 100644
--- a/range_dec.cc
+++ b/range_dec.cc
@@ -227,7 +227,7 @@ int list_files( const std::vector< std::string > & filenames,
int range_decompress( const std::string & input_filename,
const std::string & output_filename,
const std::string & range_string, const int verbosity,
- const bool force, const bool to_stdout )
+ const bool force, const bool ignore, const bool to_stdout )
{
Block range( 0, 0 );
parse_range( range_string.c_str(), range );
@@ -260,7 +260,7 @@ int range_decompress( const std::string & input_filename,
else
{ outfd = open_outstream_rw( output_filename, force );
if( outfd < 0 ) return 1; }
- Pretty_print pp( input_filename, 0 );
+ Pretty_print pp( input_filename, verbosity );
int retval = 0;
for( int i = 0; i < file_index.members(); ++i )
{
@@ -268,13 +268,15 @@ int range_decompress( const std::string & input_filename,
if( range.overlaps( db ) )
{
if( verbosity >= 3 )
- std::fprintf( stderr, "Decompressing member %3d\n", i );
+ std::fprintf( stderr, "Decompressing member %3d\n", i + 1 );
const long long outskip = std::max( 0LL, range.pos() - db.pos() );
- const long long outend = std::min( db.end(), range.end() - db.pos() );
+ const long long outend = std::min( db.size(), range.end() - db.pos() );
const long long mpos = file_index.mblock( i ).pos();
if( !safe_seek( infd, mpos ) ) { retval = 1; break; }
- retval = decompress_member( infd, outfd, pp, mpos, outskip, outend );
- if( retval ) cleanup_and_fail( output_filename, outfd, retval );
+ const int tmp = decompress_member( infd, outfd, pp, mpos, outskip, outend );
+ if( tmp && ( tmp != 2 || !ignore ) )
+ cleanup_and_fail( output_filename, outfd, tmp );
+ if( tmp > retval ) retval = tmp;
pp.reset();
}
}
@@ -284,7 +286,7 @@ int range_decompress( const std::string & input_filename,
show_error( "Error closing output file", errno );
cleanup_and_fail( output_filename, -1, 1 );
}
- if( verbosity >= 2 )
+ if( verbosity >= 2 && retval == 0 )
std::fprintf( stderr, "Byte range decompressed successfully.\n" );
return retval;
}