#pragma once #include "vcpkg_expected.h" #include "filesystem_fs.h" #include namespace vcpkg::Files { static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; bool has_invalid_chars_for_filesystem(const std::string& s); Expected read_contents(const fs::path& file_path) noexcept; Expected> read_all_lines(const fs::path& file_path); void write_all_lines(const fs::path& file_path, const std::vector& lines); fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename); template void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector* output) { std::copy_if(fs::directory_iterator(dir), fs::directory_iterator(), std::back_inserter(*output), predicate); } template void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector* output) { std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(*output), predicate); } template std::vector recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate) { std::vector v; recursive_find_matching_paths_in_dir(dir, predicate, &v); return v; } void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector* output); std::vector 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* output); std::vector recursive_find_all_files_in_dir(const fs::path& dir); void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector* output); std::vector non_recursive_find_all_files_in_dir(const fs::path& dir); void print_paths(const std::vector& paths); }