diff options
| author | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 14:59:39 +0100 |
|---|---|---|
| committer | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 14:59:39 +0100 |
| commit | cb280e48a845acc75e696433f3ec8ee7547d6fe7 (patch) | |
| tree | 81b304241684e2ee6cf6a7844bcb17176cfc9ed0 /toolsrc/src/vcpkg_Files.cpp | |
| parent | 03cdf1dc97f05b7fc290c6c6eac1306aae1605ba (diff) | |
| parent | 79399923b6cd98b9e77020615e433ef0560d5dc2 (diff) | |
| download | vcpkg-cb280e48a845acc75e696433f3ec8ee7547d6fe7.tar.gz vcpkg-cb280e48a845acc75e696433f3ec8ee7547d6fe7.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(""); + } }} |
