1
0
Fork 0

Merging upstream version 1.25.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-21 11:33:36 +01:00
parent 09c9ea500b
commit ccc1759b5f
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
40 changed files with 207 additions and 245 deletions

View file

@ -1,5 +1,5 @@
/* Lziprecover - Data recovery tool for the lzip format
Copyright (C) 2023-2024 Antonio Diaz Diaz.
Copyright (C) 2023-2025 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
@ -33,15 +33,14 @@
namespace {
/* Return true if full_name is a regular file without extension .fec
or (a link to) a directory. */
// Return true if full_name is a regular file or (a link to) a directory.
bool test_full_name( const std::string & full_name, const struct stat * stp,
const bool follow )
{
struct stat st, st2;
if( ( follow && stat( full_name.c_str(), &st ) != 0 ) ||
( !follow && lstat( full_name.c_str(), &st ) != 0 ) ) return false;
if( S_ISREG( st.st_mode ) ) return !has_fec_extension( full_name );
if( S_ISREG( st.st_mode ) ) return true;
if( !S_ISDIR( st.st_mode ) ) return false;
std::string prev_dir( full_name );
@ -62,11 +61,21 @@ bool test_full_name( const std::string & full_name, const struct stat * stp,
return !loop; // (link to) directory
}
bool ignore_name( const std::string & name )
{
if( name == "." || name == ".." || name == "fec" || name == "FEC" ||
has_fec_extension( name ) ) return true;
return name.size() > 3 && name.compare( name.size() - 3, 3, "fec" ) == 0 &&
( name.end()[-4] == '-' || name.end()[-4] == '.' ||
name.end()[-4] == '_' );
}
} // end namespace
/* Return in input_filename the next file name. ('-' is a valid file name).
Recursively found files and directories named "fec" are ignored.
Ignore recursively found files and directories named "fec" or "*[-._]fec".
Set 'retval' to 1 if a directory fails to open. */
bool next_filename( std::list< std::string > & filelist,
std::string & input_filename, int & retval,
@ -105,8 +114,7 @@ bool next_filename( std::list< std::string > & filelist,
const struct dirent * const entryp = readdir( dirp );
if( !entryp ) { closedir( dirp ); break; }
const std::string tmp_name( entryp->d_name );
if( tmp_name == "." || tmp_name == ".." || tmp_name == "fec" ||
tmp_name == "FEC" ) continue;
if( ignore_name( tmp_name ) ) continue;
const std::string full_name( input_filename + tmp_name );
if( test_full_name( full_name, stdotp, recursive == 2 ) )
tmp_list.push_back( full_name );