1
0
Fork 0

Merging upstream version 1.15~rc1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:17:40 +01:00
parent 1c5239ba60
commit 1d2507e3c4
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
20 changed files with 439 additions and 219 deletions

23
main.cc
View file

@ -1,4 +1,4 @@
/* Lziprecover - Data recovery tool for lzipped files
/* Lziprecover - Data recovery tool for lzip files
Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
@ -80,7 +80,7 @@ struct { const char * from; const char * to; } const known_extensions[] = {
{ 0, 0 } };
enum Mode { m_none, m_decompress, m_generate, m_list, m_merge, m_range,
m_recover, m_repair, m_split, m_test, m_update };
m_recover, m_repair, m_split, m_test };
std::string output_filename;
int outfd = -1;
@ -93,7 +93,7 @@ bool delete_output_on_interrupt = false;
void show_help()
{
std::printf( "%s - Data recovery tool and decompressor for lzipped files.\n", Program_name );
std::printf( "%s - Data recovery tool and decompressor for lzip files.\n", Program_name );
std::printf( "\nUsage: %s [options] [files]\n", invocation_name );
std::printf( "\nOptions:\n"
" -h, --help display this help and exit\n"
@ -149,8 +149,6 @@ void show_header( const File_header & header )
for( int i = 0; i < 8 && ( num > 9999 || ( exact && num >= factor ) ); ++i )
{ num /= factor; if( num % factor != 0 ) exact = false;
p = prefix[i]; np = ""; }
if( verbosity >= 4 )
std::fprintf( stderr, "version %d, ", header.version() );
std::fprintf( stderr, "dictionary size %s%4u %sB. ", np, num, p );
}
@ -192,7 +190,7 @@ int extension_index( const std::string & name )
} // end namespace
int open_instream( const std::string & name, struct stat * const in_statsp,
const bool to_stdout, const bool reg_only )
const bool no_ofile, const bool reg_only )
{
int infd = open( name.c_str(), O_RDONLY | o_binary );
if( infd < 0 )
@ -208,12 +206,12 @@ int open_instream( const std::string & name, struct stat * const in_statsp,
const bool can_read = ( i == 0 && !reg_only &&
( S_ISBLK( mode ) || S_ISCHR( mode ) ||
S_ISFIFO( mode ) || S_ISSOCK( mode ) ) );
if( i != 0 || ( !S_ISREG( mode ) && ( !to_stdout || !can_read ) ) )
if( i != 0 || ( !S_ISREG( mode ) && ( !can_read || !no_ofile ) ) )
{
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Input file '%s' is not a regular file%s.\n",
program_name, name.c_str(),
( can_read && !to_stdout ) ?
( can_read && !no_ofile ) ?
" and '--stdout' was not specified" : "" );
close( infd );
infd = -1;
@ -377,7 +375,7 @@ int decompress( const int infd, const Pretty_print & pp, const bool testing )
if( rdec.finished() ) // End Of File
{
if( first_member )
{ pp( "Error reading member header" ); retval = 1; }
{ pp( "File ends unexpectedly at member header" ); retval = 2; }
else if( verbosity >= 4 && size > 0 )
show_trailing_garbage( header.data, size, pp, true );
break;
@ -455,8 +453,7 @@ void set_signals()
} // end namespace
int open_outstream_rw( const std::string & output_filename,
const bool force )
int open_outstream_rw( const std::string & output_filename, const bool force )
{
int flags = O_CREAT | O_RDWR | o_binary;
if( force ) flags |= O_TRUNC; else flags |= O_EXCL;
@ -593,7 +590,6 @@ int main( const int argc, const char * const argv[] )
{
case m_generate:
case m_recover:
case m_update:
case m_none: internal_error( "invalid operation" ); break;
case m_decompress: break;
case m_list:
@ -663,7 +659,8 @@ int main( const int argc, const char * const argv[] )
else
{
input_filename = filenames[i];
infd = open_instream( input_filename, &in_stats, to_stdout );
infd = open_instream( input_filename, &in_stats,
to_stdout || program_mode == m_test );
if( infd < 0 ) { if( retval < 1 ) retval = 1; continue; }
if( program_mode != m_test )
{