diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 11:45:45 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 11:45:45 +0000 |
commit | 5e8398a39d8758cb4dee9a43f92ac958277e0ebd (patch) | |
tree | 10ba2517467532e4a002f47cc32732f1f335eae0 /main.cc | |
parent | Adding upstream version 1.16~pre1. (diff) | |
download | lziprecover-5e8398a39d8758cb4dee9a43f92ac958277e0ebd.tar.xz lziprecover-5e8398a39d8758cb4dee9a43f92ac958277e0ebd.zip |
Adding upstream version 1.16~pre2.upstream/1.16_pre2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'main.cc')
-rw-r--r-- | main.cc | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -256,17 +256,6 @@ bool open_outstream( const bool force ) } -bool check_tty( const int infd ) - { - if( isatty( infd ) ) - { - show_error( "I won't read compressed data from a terminal.", 0, true ); - return false; - } - return true; - } - - void cleanup_and_fail( const int retval ) { if( delete_output_on_interrupt ) @@ -591,6 +580,7 @@ int main( const int argc, const char * const argv[] ) if( filenames.back() != "-" ) filenames_given = true; } + try { switch( program_mode ) { case m_none: internal_error( "invalid operation." ); break; @@ -620,6 +610,9 @@ int main( const int argc, const char * const argv[] ) return split_file( filenames[0], default_output_filename, verbosity, force ); case m_test: break; } + } + catch( std::bad_alloc ) { show_error( "Not enough memory." ); return 1; } + catch( Error e ) { show_error( e.msg, errno ); return 1; } if( program_mode == m_test ) outfd = -1; @@ -683,7 +676,11 @@ int main( const int argc, const char * const argv[] ) } } - if( !check_tty( infd ) ) return 1; + if( isatty( infd ) ) + { + show_error( "I won't read compressed data from a terminal.", 0, true ); + return 1; + } if( output_filename.size() && !to_stdout && program_mode != m_test ) delete_output_on_interrupt = true; |