summaryrefslogtreecommitdiffstats
path: root/recursive.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-07-03 17:56:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-07-03 17:56:15 +0000
commit80d9d5d2b23b8ac219454d6bd8ad82eab16af6fc (patch)
tree0df0403b3f7183ed14c2be8e6c8cff1c9ac92e19 /recursive.cc
parentReleasing debian version 1.8-6. (diff)
downloadzutils-80d9d5d2b23b8ac219454d6bd8ad82eab16af6fc.tar.xz
zutils-80d9d5d2b23b8ac219454d6bd8ad82eab16af6fc.zip
Merging upstream version 1.9.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'recursive.cc')
-rw-r--r--recursive.cc38
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 ) )