summaryrefslogtreecommitdiffstats
path: root/merge.cc
diff options
context:
space:
mode:
Diffstat (limited to 'merge.cc')
-rw-r--r--merge.cc42
1 files changed, 20 insertions, 22 deletions
diff --git a/merge.cc b/merge.cc
index 01a273c..1433bf4 100644
--- a/merge.cc
+++ b/merge.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
@@ -201,8 +201,7 @@ long ipow( const unsigned base, const unsigned exponent )
int open_input_files( const std::vector< std::string > & filenames,
std::vector< int > & infd_vector,
- File_index & file_index, struct stat * const in_statsp,
- const int verbosity )
+ File_index & file_index, struct stat * const in_statsp )
{
const int files = filenames.size();
for( int i = 0; i + 1 < files; ++i )
@@ -231,7 +230,7 @@ int open_input_files( const std::vector< std::string > & filenames,
for( int i = 0; i < files; ++i )
{
long long tmp;
- const File_index fi( infd_vector[i], true, true );
+ const File_index fi( infd_vector[i], true, true, true );
if( fi.retval() == 0 ) // file format is intact
{
if( good_fi < 0 ) { good_fi = i; file_index = fi; }
@@ -290,8 +289,7 @@ int open_input_files( const std::vector< std::string > & filenames,
}
-void maybe_cluster_blocks( std::vector< Block > & block_vector,
- const int verbosity )
+void maybe_cluster_blocks( std::vector< Block > & block_vector )
{
const unsigned long old_size = block_vector.size();
if( old_size <= 16 ) return;
@@ -335,8 +333,7 @@ bool color_done( const std::vector< int > & color_vector, const int i )
bool try_merge_member2( const long long mpos, const long long msize,
const std::vector< Block > & block_vector,
const std::vector< int > & color_vector,
- const std::vector< int > & infd_vector,
- const int verbosity )
+ const std::vector< int > & infd_vector )
{
const int blocks = block_vector.size();
const int files = infd_vector.size();
@@ -380,8 +377,7 @@ bool try_merge_member2( const long long mpos, const long long msize,
bool try_merge_member( const long long mpos, const long long msize,
const std::vector< Block > & block_vector,
const std::vector< int > & color_vector,
- const std::vector< int > & infd_vector,
- const int verbosity )
+ const std::vector< int > & infd_vector )
{
const int blocks = block_vector.size();
const int files = infd_vector.size();
@@ -437,8 +433,7 @@ bool try_merge_member( const long long mpos, const long long msize,
bool try_merge_member1( const long long mpos, const long long msize,
const std::vector< Block > & block_vector,
const std::vector< int > & color_vector,
- const std::vector< int > & infd_vector,
- const int verbosity )
+ const std::vector< int > & infd_vector )
{
if( block_vector.size() != 1 || block_vector[0].size() <= 1 ) return false;
const long long pos = block_vector[0].pos();
@@ -524,10 +519,13 @@ bool test_member_from_file( const int infd, const unsigned long long msize,
header.verify_version() && isvalid_ds( dictionary_size ) )
{
LZ_decoder decoder( rdec, dictionary_size, -1 );
- Pretty_print dummy( "", -1 );
-
- if( decoder.decode_member( dummy ) == 0 &&
- rdec.member_position() == msize ) return true;
+ const int old_verbosity = verbosity;
+ verbosity = -1; // suppress all messages
+ Pretty_print dummy( "" );
+ const bool done = ( decoder.decode_member( dummy ) == 0 &&
+ rdec.member_position() == msize );
+ verbosity = old_verbosity; // restore verbosity level
+ if( done ) return true;
}
if( failure_posp ) *failure_posp = rdec.member_position();
return false;
@@ -536,14 +534,14 @@ bool test_member_from_file( const int infd, const unsigned long long msize,
int merge_files( const std::vector< std::string > & filenames,
const std::string & default_output_filename,
- const int verbosity, const bool force )
+ const bool force )
{
const int files = filenames.size();
std::vector< int > infd_vector( files );
File_index file_index;
struct stat in_stats;
const int retval =
- open_input_files( filenames, infd_vector, file_index, &in_stats, verbosity );
+ open_input_files( filenames, infd_vector, file_index, &in_stats );
if( retval >= 0 ) return retval;
if( !safe_seek( infd_vector[0], 0 ) ) return 1;
@@ -588,22 +586,22 @@ int merge_files( const std::vector< std::string > & filenames,
{
if( block_vector.size() > 1 )
{
- maybe_cluster_blocks( block_vector, verbosity );
+ maybe_cluster_blocks( block_vector );
done = try_merge_member2( mpos, msize, block_vector, color_vector,
- infd_vector, verbosity );
+ infd_vector );
print_pending_newline();
}
if( !done )
{
done = try_merge_member( mpos, msize, block_vector, color_vector,
- infd_vector, verbosity );
+ infd_vector );
print_pending_newline();
}
}
if( !done )
{
done = try_merge_member1( mpos, msize, block_vector, color_vector,
- infd_vector, verbosity );
+ infd_vector );
print_pending_newline();
}
if( !done )