diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 11:13:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-06-16 11:13:24 +0000 |
commit | d7c278fca708bc2c4badaeac041ecb136a4ef955 (patch) | |
tree | 5b163b83e6e3171a311f67187aa75c0f96f98f13 /split.cc | |
parent | Adding upstream version 1.23. (diff) | |
download | lziprecover-d7c278fca708bc2c4badaeac041ecb136a4ef955.tar.xz lziprecover-d7c278fca708bc2c4badaeac041ecb136a4ef955.zip |
Adding upstream version 1.24~pre1.upstream/1.24_pre1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | split.cc | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -1,5 +1,5 @@ /* Lziprecover - Data recovery tool for the lzip format - Copyright (C) 2009-2022 Antonio Diaz Diaz. + Copyright (C) 2009-2023 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 @@ -68,43 +68,44 @@ bool next_filename( const int max_digits ) int split_file( const std::string & input_filename, - const std::string & default_output_filename, const bool force ) + const std::string & default_output_filename, + const Cl_options & cl_opts, const bool force ) { + const char * const filename = input_filename.c_str(); struct stat in_stats; - const int infd = - open_instream( input_filename.c_str(), &in_stats, false, true ); + const int infd = open_instream( filename, &in_stats, false, true ); if( infd < 0 ) return 1; - Lzip_index lzip_index( infd, true, true, true, true ); + Lzip_index lzip_index( infd, cl_opts, true, true ); if( lzip_index.retval() != 0 ) { - show_file_error( input_filename.c_str(), lzip_index.error().c_str() ); + show_file_error( filename, lzip_index.error().c_str() ); return lzip_index.retval(); } - // verify last member + // check last member const Block b = lzip_index.mblock( lzip_index.members() - 1 ); long long mpos = b.pos(); long long msize = b.size(); long long failure_pos = 0; - if( !safe_seek( infd, mpos ) ) return 1; + if( !safe_seek( infd, mpos, filename ) ) return 1; if( test_member_from_file( infd, msize, &failure_pos ) == 1 ) { // corrupt or fake trailer while( true ) { mpos += failure_pos; msize -= failure_pos; if( msize < min_member_size ) break; // trailing data - if( !safe_seek( infd, mpos ) ) return 1; + if( !safe_seek( infd, mpos, filename ) ) return 1; if( test_member_from_file( infd, msize, &failure_pos ) != 1 ) break; } - lzip_index = Lzip_index( infd, true, true, true, true, mpos ); + lzip_index = Lzip_index( infd, cl_opts, true, true, mpos ); if( lzip_index.retval() != 0 ) { - show_file_error( input_filename.c_str(), lzip_index.error().c_str() ); + show_file_error( filename, lzip_index.error().c_str() ); return lzip_index.retval(); } } - if( !safe_seek( infd, 0 ) ) return 1; + if( !safe_seek( infd, 0, filename ) ) return 1; int max_digits = 1; for( long i = lzip_index.blocks( true ); i >= 10; i /= 10 ) ++max_digits; first_filename( input_filename, default_output_filename, max_digits ); |