#pragma once #include #include #include #include #include #include #include #include namespace files { namespace fs = std::filesystem; inline std::vector findFilesWithExtension(const std::string path, const std::string ext) { std::vector out; std::unordered_set seen; // canonicalized paths to dedupe std::error_code ec; fs::path p(path); if (!fs::exists(p, ec) || !fs::is_directory(p, ec)) return out; for (const auto &entry : fs::directory_iterator(p, ec)) { if (ec) { ec.clear(); continue; } const auto &filePath = entry.path(); if (filePath.extension() == ext && fs::is_regular_file(filePath, ec)) { out.push_back(filePath); } } return out; } inline std::string readFile(const std::string &filename) { std::ifstream in(filename); if (!in) throw std::runtime_error("Could not open file"); std::ostringstream ss; ss << in.rdbuf(); // dump entire buffer into string return ss.str(); } }