summaryrefslogtreecommitdiffstats
path: root/merge.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--merge.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/merge.cc b/merge.cc
index 509c94f..2951b50 100644
--- a/merge.cc
+++ b/merge.cc
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
- Copyright (C) 2009-2023 Antonio Diaz Diaz.
+ Copyright (C) 2009-2024 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
@@ -549,7 +549,7 @@ int test_member_from_file( const int infd, const unsigned long long msize,
{
Range_decoder rdec( infd );
Lzip_header header;
- rdec.read_data( header.data, Lzip_header::size );
+ rdec.read_data( header.data, header.size );
const unsigned dictionary_size = header.dictionary_size();
bool done = false;
if( !rdec.finished() && header.check_magic() &&
@@ -558,8 +558,7 @@ int test_member_from_file( const int infd, const unsigned long long msize,
LZ_decoder decoder( rdec, dictionary_size, -1 );
const int saved_verbosity = verbosity;
verbosity = -1; // suppress all messages
- Pretty_print dummy_pp( "" );
- done = ( decoder.decode_member( dummy_pp ) == 0 );
+ done = decoder.decode_member() == 0;
verbosity = saved_verbosity; // restore verbosity level
if( done && rdec.member_position() == msize ) return 0;
}
@@ -582,10 +581,11 @@ int merge_files( const std::vector< std::string > & filenames,
if( retval >= 0 ) return retval;
if( !safe_seek( infd_vector[0], 0, filenames[0].c_str() ) ) return 1;
- output_filename = default_output_filename.empty() ?
- insert_fixed( filenames[0] ) : default_output_filename;
+ const bool to_file = default_output_filename.size();
+ output_filename =
+ to_file ? default_output_filename : insert_fixed( filenames[0] );
set_signal_handler();
- if( !open_outstream( force, true, true, false ) ) return 1;
+ if( !open_outstream( force, true, true, false, to_file ) ) return 1;
if( !copy_file( infd_vector[0], outfd ) ) // copy whole file
cleanup_and_fail( 1 );
@@ -651,7 +651,7 @@ int merge_files( const std::vector< std::string > & filenames,
}
}
- if( close_outstream( &in_stats ) != 0 ) return 1;
+ if( !close_outstream( &in_stats ) ) return 1;
if( verbosity >= 1 )
std::fputs( "Input files merged successfully.\n", stdout );
return 0;