1
0
Fork 0

Adding upstream version 0.25.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 21:27:24 +01:00
parent 4f5d0de2b2
commit 8853aa3bf2
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
33 changed files with 317 additions and 280 deletions

View file

@ -1,5 +1,5 @@
/* Tarlz - Archiver with multimember lzip compression
Copyright (C) 2013-2023 Antonio Diaz Diaz.
Copyright (C) 2013-2024 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
@ -53,12 +53,11 @@ void cleanup_and_fail( const int retval )
if( delete_output_on_interrupt )
{
delete_output_on_interrupt = false;
if( verbosity >= 0 )
std::fprintf( stderr, "%s: Deleting output file '%s', if it exists.\n",
program_name, output_filename.c_str() );
show_file_error( output_filename.c_str(),
"Deleting output file, if it exists." );
if( outfd >= 0 ) { close( outfd ); outfd = -1; }
if( std::remove( output_filename.c_str() ) != 0 && errno != ENOENT )
show_error( "WARNING: deletion of output file (apparently) failed." );
show_error( "warning: deletion of output file failed", errno );
}
std::exit( retval );
}
@ -103,7 +102,7 @@ void close_and_set_permissions( const struct stat * const in_statsp )
if( in_statsp )
{
const mode_t mode = in_statsp->st_mode;
// fchown will in many cases return with EPERM, which can be safely ignored.
// fchown in many cases returns with EPERM, which can be safely ignored.
if( fchown( outfd, in_statsp->st_uid, in_statsp->st_gid ) == 0 )
{ if( fchmod( outfd, mode ) != 0 ) warning = true; }
else
@ -112,10 +111,8 @@ void close_and_set_permissions( const struct stat * const in_statsp )
warning = true;
}
if( close( outfd ) != 0 )
{
show_error( "Error closing output file", errno );
cleanup_and_fail( 1 );
}
{ show_file_error( output_filename.c_str(), "Error closing output file",
errno ); cleanup_and_fail( 1 ); }
outfd = -1;
delete_output_on_interrupt = false;
if( in_statsp )
@ -126,7 +123,8 @@ void close_and_set_permissions( const struct stat * const in_statsp )
if( utime( output_filename.c_str(), &t ) != 0 ) warning = true;
}
if( warning && verbosity >= 1 )
show_error( "Can't change output file attributes." );
show_file_error( output_filename.c_str(),
"warning: can't change output file attributes", errno );
}
@ -233,6 +231,9 @@ int compress_archive( const Cl_options & cl_opts,
if( to_file && outfd < 0 && ( is_header || is_zero ) )
{
// open outfd after checking infd
if( !make_dirs( output_filename ) )
{ show_file_error( output_filename.c_str(), intdir_msg, errno );
return 1; }
outfd = open_outstream( output_filename, true, 0, false );
// check tty only once and don't try to delete a tty
if( outfd < 0 || !check_tty_out() ) { close( infd ); return 1; }