summaryrefslogtreecommitdiffstats
path: root/range_dec.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--range_dec.cc31
1 files changed, 14 insertions, 17 deletions
diff --git a/range_dec.cc b/range_dec.cc
index e105aaa..803a540 100644
--- a/range_dec.cc
+++ b/range_dec.cc
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
- Copyright (C) 2009-2017 Antonio Diaz Diaz.
+ Copyright (C) 2009-2018 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -51,13 +51,13 @@ int decompress_member( const int infd, const Pretty_print & pp,
if( !isvalid_ds( dictionary_size ) )
{ pp( "Invalid dictionary size in member header." ); return 2; }
- if( pp.verbosity() >= 2 ) { pp(); show_header( dictionary_size ); }
+ if( verbosity >= 2 ) pp();
LZ_decoder decoder( rdec, dictionary_size, outfd, outskip, outend );
const int result = decoder.decode_member( pp );
if( result != 0 )
{
- if( pp.verbosity() >= 0 && result <= 2 )
+ if( verbosity >= 0 && result <= 2 )
{
pp();
std::fprintf( stderr, "%s at pos %llu\n", ( result == 2 ) ?
@@ -66,7 +66,7 @@ int decompress_member( const int infd, const Pretty_print & pp,
}
return 2;
}
- if( pp.verbosity() >= 2 ) std::fputs( "done\n", stderr );
+ if( verbosity >= 2 ) std::fputs( "done\n", stderr );
return 0;
}
@@ -109,16 +109,17 @@ bool safe_seek( const int fd, const long long pos )
int range_decompress( const std::string & input_filename,
const std::string & default_output_filename,
- Block range, const int verbosity, const bool force,
- const bool ignore_errors, const bool ignore_trailing,
+ Block range, const bool force, const bool ignore_errors,
+ const bool ignore_trailing, const bool loose_trailing,
const bool to_stdout )
{
struct stat in_stats;
const int infd = open_instream( input_filename.c_str(), &in_stats, true, true );
if( infd < 0 ) return 1;
- Pretty_print pp( input_filename, verbosity );
- const File_index file_index( infd, ignore_errors, ignore_trailing );
+ Pretty_print pp( input_filename );
+ const File_index file_index( infd, ignore_errors, ignore_trailing,
+ loose_trailing );
if( file_index.retval() != 0 )
{ show_file_error( input_filename.c_str(), file_index.error().c_str() );
return file_index.retval(); }
@@ -126,18 +127,14 @@ int range_decompress( const std::string & input_filename,
if( range.end() > file_index.udata_size() )
range.size( std::max( 0LL, file_index.udata_size() - range.pos() ) );
if( range.size() <= 0 )
- { if( verbosity >= 0 ) pp( "Nothing to do." ); return 0; }
+ { pp( "Nothing to do." ); return 0; }
if( verbosity >= 1 )
- {
- if( verbosity >= 2 )
- std::fprintf( stderr, "Decompressed file size = %sB\n",
- format_num( file_index.udata_size() ) );
- std::fprintf( stderr, "Decompressing range %sB to %sB (%sBytes)\n",
+ std::fprintf( stderr, "Decompressing range %sB to %sB (%sof %sBytes)\n",
format_num( range.pos() ),
format_num( range.pos() + range.size() ),
- format_num( range.size() ) );
- }
+ format_num( range.size() ),
+ format_num( file_index.udata_size() ) );
if( to_stdout || default_output_filename.empty() )
outfd = STDOUT_FILENO;
@@ -154,7 +151,7 @@ int range_decompress( const std::string & input_filename,
const Block & db = file_index.dblock( i );
if( range.overlaps( db ) )
{
- if( verbosity >= 3 )
+ if( verbosity >= 3 && file_index.members() > 1 )
std::fprintf( stderr, "Decompressing member %3ld\n", i + 1 );
const long long outskip = std::max( 0LL, range.pos() - db.pos() );
const long long outend = std::min( db.size(), range.end() - db.pos() );