Merging upstream version 1.9.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
3e7d50525b
commit
13941d3cbe
30 changed files with 1188 additions and 1060 deletions
38
recursive.cc
38
recursive.cc
|
@ -1,22 +1,22 @@
|
|||
/* Zutils - Utilities dealing with compressed files
|
||||
Copyright (C) 2009-2019 Antonio Diaz Diaz.
|
||||
/* Zutils - Utilities dealing with compressed files
|
||||
Copyright (C) 2009-2020 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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Returns true if full_name is a regular file with an enabled extension
|
||||
// or (a link to) a directory.
|
||||
/* Returns true if full_name is a regular file with an enabled extension
|
||||
or (a link to) a directory. */
|
||||
bool test_full_name( const std::string & full_name, const struct stat * stp,
|
||||
const bool follow )
|
||||
{
|
||||
|
@ -41,12 +41,14 @@ bool test_full_name( const std::string & full_name, const struct stat * stp,
|
|||
{ loop = true; break; }
|
||||
}
|
||||
if( loop ) // full_name already visited or above tree
|
||||
show_file_error( full_name.c_str(), "warning: Recursive directory loop" );
|
||||
show_file_error( full_name.c_str(), "warning: Recursive directory loop." );
|
||||
return !loop; // (link to) directory
|
||||
}
|
||||
|
||||
|
||||
// Returns in input_filename the next filename.
|
||||
/* Returns in input_filename the next filename, or "." for stdin.
|
||||
("." was chosen because it is not a valid filename).
|
||||
Sets 'error' to true if a directory fails to open. */
|
||||
bool next_filename( std::list< std::string > & filenames,
|
||||
std::string & input_filename, bool & error,
|
||||
const int recursive, const bool ignore_stdin = false,
|
||||
|
@ -56,10 +58,10 @@ bool next_filename( std::list< std::string > & filenames,
|
|||
{
|
||||
input_filename = filenames.front();
|
||||
filenames.pop_front();
|
||||
if( input_filename.empty() || input_filename == "-" )
|
||||
if( input_filename == "-" )
|
||||
{
|
||||
if( ignore_stdin ) continue;
|
||||
input_filename.clear(); return true;
|
||||
input_filename = "."; return true;
|
||||
}
|
||||
struct stat st;
|
||||
if( stat( input_filename.c_str(), &st ) == 0 && S_ISDIR( st.st_mode ) )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue