[Files] Add functions to get all files of a dir recursively or non-recursively

This commit is contained in:
Alexander Karatarakis 2016-11-29 18:08:00 -08:00
parent 0da18a3d53
commit 0b996a002e
2 changed files with 38 additions and 0 deletions

View File

@ -41,4 +41,12 @@ namespace vcpkg {namespace Files
void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output);
std::vector<fs::path> recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension);
void recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output);
std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir);
void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output);
std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir);
}}

View File

@ -73,4 +73,34 @@ namespace vcpkg {namespace Files
recursive_find_files_with_extension_in_dir(dir, extension, &v);
return v;
}
void recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output)
{
recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current)
{
return !fs::is_directory(current);
}, output);
}
std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir)
{
std::vector<fs::path> v;
recursive_find_all_files_in_dir(dir, &v);
return v;
}
void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output)
{
non_recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current)
{
return !fs::is_directory(current);
}, output);
}
std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir)
{
std::vector<fs::path> v;
non_recursive_find_all_files_in_dir(dir, &v);
return v;
}
}}