summaryrefslogtreecommitdiffstats
path: root/merge.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--merge.cc35
1 files changed, 7 insertions, 28 deletions
diff --git a/merge.cc b/merge.cc
index aaccb56..08a3d0e 100644
--- a/merge.cc
+++ b/merge.cc
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for lzip files
- Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
+ Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 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
@@ -167,7 +167,7 @@ int open_input_files( const std::vector< std::string > & filenames,
struct stat in_stats;
ino_t st_ino0 = 0;
dev_t st_dev0 = 0;
- infd_vector[i] = open_instream( filenames[i], &in_stats, true, true );
+ infd_vector[i] = open_instream( filenames[i].c_str(), &in_stats, true, true );
if( infd_vector[i] < 0 ) return 1;
if( i == 0 ) { st_ino0 = in_stats.st_ino; st_dev0 = in_stats.st_dev; }
else if( st_ino0 == in_stats.st_ino && st_dev0 == in_stats.st_dev )
@@ -192,8 +192,7 @@ int open_input_files( const std::vector< std::string > & filenames,
tmp = lseek( infd_vector[i], 0, SEEK_END );
if( tmp < 0 )
{
- if( verbosity >= 0 )
- std::fprintf( stderr, "File '%s' is not seekable.\n", filenames[i].c_str() );
+ show_error2( "Input file", filenames[i].c_str(), "is not seekable." );
return 1;
}
}
@@ -201,7 +200,8 @@ int open_input_files( const std::vector< std::string > & filenames,
{
isize = tmp;
if( isize < min_member_size )
- { show_error( "Input file is too short." ); return 2; }
+ { show_error2( "Input file", filenames[i].c_str(), "is too short." );
+ return 2; }
}
else if( isize != tmp )
{ show_error( "Sizes of input files are different." ); return 2; }
@@ -302,33 +302,12 @@ bool try_decompress_member( const int fd, const unsigned long long msize,
}
}
catch( std::bad_alloc )
- {
- show_error( "Not enough memory. Find a machine with more memory." );
- std::exit( 1 );
- }
+ { show_error( "Not enough memory." ); std::exit( 1 ); }
catch( Error e ) {}
return false;
}
-bool verify_header( const File_header & header, const int verbosity )
- {
- if( !header.verify_magic() )
- {
- show_error( "Bad magic number (file not in lzip format)." );
- return false;
- }
- if( !header.verify_version() )
- {
- if( verbosity >= 0 )
- std::fprintf( stderr, "Version %d member format not supported.\n",
- header.version() );
- return false;
- }
- return true;
- }
-
-
int merge_files( const std::vector< std::string > & filenames,
const std::string & output_filename, const int verbosity,
const bool force )
@@ -356,7 +335,7 @@ int merge_files( const std::vector< std::string > & filenames,
!safe_seek( outfd, mpos ) )
cleanup_and_fail( output_filename, outfd, 1 );
- if( block_vector.size() == 0 )
+ if( block_vector.empty() )
{
if( file_index.members() > 1 && try_decompress_member( outfd, msize ) )
continue;