From 19bf9bf2f2650cfb1bc9528a8d6f50a33b55d145 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 3 Jul 2020 19:56:10 +0200 Subject: Adding upstream version 1.9. Signed-off-by: Daniel Baumann --- recursive.cc | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'recursive.cc') diff --git a/recursive.cc b/recursive.cc index 2f347f9..1b77a28 100644 --- a/recursive.cc +++ b/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 . + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ -// 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 ) ) -- cgit v1.2.3