diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 11:45:12 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 11:45:12 +0000 |
commit | 2085b1344e4c2b3c4a3d21d4bc10227679a55507 (patch) | |
tree | 86328decac9bdf54fb41b6af1bd15b23fff1edd7 /merge.cc | |
parent | Adding debian version 1.15-2. (diff) | |
download | lziprecover-2085b1344e4c2b3c4a3d21d4bc10227679a55507.tar.xz lziprecover-2085b1344e4c2b3c4a3d21d4bc10227679a55507.zip |
Merging upstream version 1.16~pre1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | merge.cc | 35 |
1 files changed, 7 insertions, 28 deletions
@@ -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; |