summaryrefslogtreecommitdiffstats
path: root/split.cc
diff options
context:
space:
mode:
Diffstat (limited to 'split.cc')
-rw-r--r--split.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/split.cc b/split.cc
index 269f051..9d3304e 100644
--- a/split.cc
+++ b/split.cc
@@ -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 );