summaryrefslogtreecommitdiffstats
path: root/main.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:42:39 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:42:39 +0000
commit04d72dd06c3c49fcc61e5ae7b8cee112d34e8df1 (patch)
treeaadf6684ddb287ecaaa4bfc482ab8859ce3742cb /main.cc
parentAdding debian version 1.15~pre1-2. (diff)
downloadlziprecover-04d72dd06c3c49fcc61e5ae7b8cee112d34e8df1.tar.xz
lziprecover-04d72dd06c3c49fcc61e5ae7b8cee112d34e8df1.zip
Merging upstream version 1.15~rc1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--main.cc23
1 files changed, 10 insertions, 13 deletions
diff --git a/main.cc b/main.cc
index 21a5b04..19d4324 100644
--- a/main.cc
+++ b/main.cc
@@ -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 )
{