1
0
Fork 0

Adding upstream version 1.18.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:26:09 +01:00
parent ed1b0d872f
commit f46d8ce0c8
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
45 changed files with 1576 additions and 774 deletions

View file

@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
Copyright (C) 2009-2015 Antonio Diaz Diaz.
Copyright (C) 2009-2016 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
@ -17,6 +17,7 @@
#define _FILE_OFFSET_BITS 64
#include <algorithm>
#include <cerrno>
#include <climits>
#include <cstdio>
@ -36,12 +37,10 @@ namespace {
void first_filename( const std::string & input_filename,
const std::string & default_output_filename,
std::string & output_filename, const int max_digits )
const int max_digits )
{
if( default_output_filename.size() )
output_filename = default_output_filename;
else
output_filename = input_filename;
output_filename = default_output_filename.empty() ?
input_filename : default_output_filename;
int b = output_filename.size();
while( b > 0 && output_filename[b-1] != '/' ) --b;
output_filename.insert( b, "rec1" );
@ -49,7 +48,7 @@ void first_filename( const std::string & input_filename,
}
bool next_filename( std::string & output_filename, const int max_digits )
bool next_filename( const int max_digits )
{
int b = output_filename.size();
while( b > 0 && output_filename[b-1] != '/' ) --b;
@ -114,11 +113,9 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
int max_digits = 1;
for( long i = max_members; i >= 10; i /= 10 ) ++max_digits;
std::string output_filename;
first_filename( input_filename, default_output_filename, output_filename,
max_digits );
int outfd = open_outstream_rw( output_filename, force );
if( outfd < 0 ) { close( infd ); return 1; }
first_filename( input_filename, default_output_filename, max_digits );
if( !open_outstream( force, false, false, false ) )
{ close( infd ); return 1; }
unsigned long long partial_member_size = 0;
while( true )
@ -135,17 +132,16 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
const int wr = writeblock( outfd, buffer + pos, newpos - pos );
if( wr != newpos - pos )
{ show_error( "Write error", errno ); return 1; }
if( close( outfd ) != 0 )
{ show_error( "Error closing output file", errno ); return 1; }
if( close_outstream( &in_stats ) != 0 ) return 1;
if( verbosity >= 1 )
{
std::printf( "Member '%s' done \r", output_filename.c_str() );
std::fflush( stdout );
}
if( !next_filename( output_filename, max_digits ) )
if( !next_filename( max_digits ) )
{ show_error( "Too many members in file." ); close( infd ); return 1; }
outfd = open_outstream_rw( output_filename, force );
if( outfd < 0 ) { close( infd ); return 1; }
if( !open_outstream( force, false, false, false ) )
{ close( infd ); return 1; }
partial_member_size = 0;
pos = newpos;
}
@ -173,8 +169,7 @@ int do_split_file( const std::string & input_filename, uint8_t * & base_buffer,
{ show_error( "Read error", errno ); return 1; }
}
close( infd );
if( close( outfd ) != 0 )
{ show_error( "Error closing output file", errno ); return 1; }
if( close_outstream( &in_stats ) != 0 ) return 1;
if( verbosity >= 1 )
{
std::printf( "Member '%s' done \n", output_filename.c_str() );