diff options
Diffstat (limited to '')
-rw-r--r-- | recursive.cc | 38 |
1 files changed, 20 insertions, 18 deletions
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 <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 ) ) |