diff options
| author | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 08:59:01 +0100 |
|---|---|---|
| committer | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 08:59:01 +0100 |
| commit | 7f9353dd9541ca15ebefa66e531e4bac4ad7c871 (patch) | |
| tree | d1775b00285b0583c71163b3d219f9c539536399 /toolsrc/src/vcpkg_Files.cpp | |
| parent | 5a04753a4a99a6210990b25e8773b86ccbffec0b (diff) | |
| parent | 223e7f970d30d3d97e64af3d1970d52cc0ddaaf5 (diff) | |
| download | vcpkg-7f9353dd9541ca15ebefa66e531e4bac4ad7c871.tar.gz vcpkg-7f9353dd9541ca15ebefa66e531e4bac4ad7c871.zip | |
Merge branch 'master' of https://github.com/Microsoft/vcpkg into qca
Diffstat (limited to 'toolsrc/src/vcpkg_Files.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_Files.cpp | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 611aa7450..698579736 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -1,9 +1,7 @@ #include "vcpkg_Files.h" #include <fstream> -#include <filesystem> #include <regex> - -namespace fs = std::tr2::sys; +#include "vcpkg_System.h" namespace vcpkg {namespace Files { @@ -58,4 +56,59 @@ namespace vcpkg {namespace Files return current_dir; } + + void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output) + { + recursive_find_matching_paths_in_dir(dir, [&extension](const fs::path& current) + { + return !fs::is_directory(current) && current.extension() == extension; + }, output); + } + + std::vector<fs::path> recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension) + { + std::vector<fs::path> v; + 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; + } + + void print_paths(const std::vector<fs::path>& paths) + { + System::println(""); + for (const fs::path& p : paths) + { + System::println(" %s", p.generic_string()); + } + System::println(""); + } }} |
