* Helper to see whether a given filename matches the extension. * @param extension The extension to look for. * @param filename The filename to look in for the extension. * @return True iff the extension is nullptr, or the filename ends with it. */
| 1049 | * @return True iff the extension is nullptr, or the filename ends with it. |
| 1050 | */ |
| 1051 | static bool MatchesExtension(std::string_view extension, const std::string &filename) |
| 1052 | { |
| 1053 | if (extension.empty()) return true; |
| 1054 | if (filename.length() < extension.length()) return false; |
| 1055 | |
| 1056 | std::string_view filename_sv = filename; // String view to avoid making another copy of the substring. |
| 1057 | return StrCompareIgnoreCase(extension, filename_sv.substr(filename_sv.length() - extension.length())) == 0; |
| 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * Scan a single directory (and recursively its children) and add |
no test coverage detected