summaryrefslogtreecommitdiffstats
path: root/dump_remove.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dump_remove.cc')
-rw-r--r--dump_remove.cc17
1 files changed, 11 insertions, 6 deletions
diff --git a/dump_remove.cc b/dump_remove.cc
index 92b5e3d..3273303 100644
--- a/dump_remove.cc
+++ b/dump_remove.cc
@@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
- Copyright (C) 2009-2023 Antonio Diaz Diaz.
+ Copyright (C) 2009-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
@@ -32,6 +32,9 @@
#include "lzip_index.h"
+const char * const pdate_msg = "warning: can't preserve file date";
+
+
/* If strip is false, dump to outfd members/gaps/tdata in member_list.
If strip is true, dump to outfd members/gaps/tdata not in member_list. */
int dump_members( const std::vector< std::string > & filenames,
@@ -134,7 +137,7 @@ int dump_members( const std::vector< std::string > & filenames,
else if( trailing_size > 0 ) { stripped_tsize += trailing_size; ++tfiles; }
close( infd );
}
- if( close_outstream( 0 ) != 0 ) set_retval( retval, 1 );
+ if( !close_outstream( 0 ) ) set_retval( retval, 1 );
if( verbosity >= 1 )
{
if( !strip )
@@ -275,7 +278,8 @@ int remove_members( const std::vector< std::string > & filenames,
struct utimbuf t;
t.actime = in_stats.st_atime;
t.modtime = in_stats.st_mtime;
- utime( filename, &t );
+ if( utime( filename, &t ) != 0 && verbosity >= 1 )
+ show_file_error( filename, pdate_msg, errno );
}
if( verbosity >= 1 )
{
@@ -320,7 +324,7 @@ int clear_marking( const std::vector< std::string > & filenames,
uint8_t header_buf[bufsize];
const uint8_t * const p = header_buf; // keep gcc 6.1.0 quiet
const Lzip_header & header = *(const Lzip_header *)p;
- uint8_t * const mark = header_buf + Lzip_header::size;
+ uint8_t * const mark = header_buf + header.size;
bool write_attempted = false;
for( long j = 0; j < lzip_index.members(); ++j ) // clear the members
{
@@ -333,7 +337,7 @@ int clear_marking( const std::vector< std::string > & filenames,
set_retval( retval, 2 ); break; }
if( *mark == 0 ) continue;
*mark = 0; write_attempted = true;
- if( seek_write( fd, mark, 1, mb.pos() + Lzip_header::size ) != 1 )
+ if( seek_write( fd, mark, 1, mb.pos() + header.size ) != 1 )
{ show_file_error( filename, "Error writing to file", errno );
set_retval( retval, 1 ); break; }
++cleared_members;
@@ -348,7 +352,8 @@ int clear_marking( const std::vector< std::string > & filenames,
struct utimbuf t;
t.actime = in_stats.st_atime;
t.modtime = in_stats.st_mtime;
- utime( filename, &t );
+ if( utime( filename, &t ) != 0 && verbosity >= 1 )
+ show_file_error( filename, pdate_msg, errno );
++files;
}
}