| 127 | } |
| 128 | |
| 129 | std::vector<std::filesystem::path> globFilesInDirectory( |
| 130 | const std::filesystem::path& path, |
| 131 | const std::regex& regexPattern, |
| 132 | bool firstMatchOnly |
| 133 | ) |
| 134 | { |
| 135 | std::vector<std::filesystem::path> result; |
| 136 | if (!std::filesystem::exists(path)) |
| 137 | return result; |
| 138 | for (const auto& entry : std::filesystem::directory_iterator(path)) |
| 139 | { |
| 140 | if (!entry.is_regular_file()) |
| 141 | continue; |
| 142 | std::string filename = entry.path().filename().string(); |
| 143 | if (std::regex_match(filename, regexPattern)) |
| 144 | { |
| 145 | result.push_back(entry.path()); |
| 146 | if (firstMatchOnly) |
| 147 | return result; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | return result; |
| 152 | } |
| 153 | |
| 154 | std::vector<std::filesystem::path> globFilesInDirectories( |
| 155 | const std::filesystem::path& path, |
no test coverage detected