Fix recursive scanning of directories

ForeachDirectoryEntry didn't actually do anything with the `recursive`
parameter, and the corresponding callback parameter was shadowing the
actual recursion counters in the user functions.
This commit is contained in:
Yuri Kunde Schlesner 2016-06-19 00:09:16 -07:00
parent 8f86cc4df9
commit d6792632f0
3 changed files with 15 additions and 22 deletions

View file

@ -105,13 +105,11 @@ 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<bool(unsigned* num_entries_out,
const std::string& directory,
const std::string& virtual_name,
unsigned int recursion)>;
const std::string& virtual_name)>;
/**
* Scans a directory, calling the callback for each file/directory contained within.
@ -119,10 +117,9 @@ using DirectoryEntryCallable = std::function<bool(unsigned* num_entries_out,
* @param num_entries_out assigned by the function with the number of iterated directory entries, can be null
* @param directory the directory to scan
* @param callback The callback which will be called for each entry
* @param recursion Number of children directories to read before giving up
* @return whether scanning the directory succeeded
*/
bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback, unsigned int recursion = 0);
bool ForeachDirectoryEntry(unsigned* num_entries_out, const std::string &directory, DirectoryEntryCallable callback);
/**
* Scans the directory tree, storing the results.