| 230 | } |
| 231 | |
| 232 | bool hasExtension(const std::filesystem::path& path, std::string_view ext) |
| 233 | { |
| 234 | // Remove leading '.' from ext. |
| 235 | if (ext.size() > 0 && ext[0] == '.') |
| 236 | ext.remove_prefix(1); |
| 237 | |
| 238 | std::string pathExt = getExtensionFromPath(path); |
| 239 | |
| 240 | if (ext.size() != pathExt.size()) |
| 241 | return false; |
| 242 | |
| 243 | return std::equal(ext.rbegin(), ext.rend(), pathExt.rbegin(), [](char a, char b) { return std::tolower(a) == std::tolower(b); }); |
| 244 | } |
| 245 | |
| 246 | std::string getExtensionFromPath(const std::filesystem::path& path) |
| 247 | { |