ensure elements in deepest dir are added to output list

develop
Myk Taylor 2023-03-11 02:01:50 -08:00
parent 902985d6f9
commit 9b7860125d
No known key found for this signature in database
1 changed files with 4 additions and 1 deletions

@ -255,13 +255,14 @@ static int listdir_recursive_impl (std::string prefix, std::string path,
std::string path_file = path + *file;
if (Filesystem::isdir(prefixed_file))
{
files.insert(std::pair<std::string, bool>(include_prefix ? prefixed_file : path_file, true));
if (depth == 0)
{
out_of_depth = true;
continue;
}
files.insert(std::pair<std::string, bool>(include_prefix ? prefixed_file : path_file, true));
err = listdir_recursive_impl(prefix, path_file + "/", files, depth - 1, include_prefix);
if (err)
return err;
@ -277,5 +278,7 @@ static int listdir_recursive_impl (std::string prefix, std::string path,
int Filesystem::listdir_recursive (std::string dir, std::map<std::string, bool> &files,
int depth /* = 10 */, bool include_prefix /* = true */)
{
if (dir.size() && dir[dir.size()-1] == '/')
dir.resize(dir.size()-1);
return listdir_recursive_impl(dir, "", files, depth, include_prefix);
}