From 8ab6f26c09e5b77a051fa545570ca2986c45bf4a Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 6 Sep 2015 07:59:04 +0100 Subject: Common: Make recursive FileUtil functions take a maximum recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1115. Also improves the performances of DiskArchive’s directory implementation a lot, simply by not going through the entire tree instead of just listing the first level files. Thanks to JayRoxFox for rebasing this on current master! --- src/common/file_util.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/common/file_util.h') diff --git a/src/common/file_util.h b/src/common/file_util.h index c6a8694ce..32ae2dc57 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -105,11 +105,13 @@ bool CreateEmptyFile(const std::string &filename); * @param num_entries_out to be assigned by the callable with the number of iterated directory entries, never null * @param directory the path to the enclosing directory * @param virtual_name the entry name, without any preceding directory info + * @param recursion Number of children directory to read before giving up * @return whether handling the entry succeeded */ using DirectoryEntryCallable = std::function; + const std::string& virtual_name, + unsigned int recursion)>; /** * Scans a directory, calling the callback for each file/directory contained within. @@ -117,20 +119,22 @@ using DirectoryEntryCallable = std::function