createFileExcluder function
A test for the files a walk should not read, over the file's own name.
Implementation
bool Function(String) createFileExcluder(Iterable<String> patterns) {
final exact = <String>{};
final globs = <String>[];
for (final pattern in patterns) {
if (pattern.isEmpty) {
continue;
}
if (pattern.contains('*')) {
globs.add(pattern);
} else {
exact.add(pattern.toLowerCase());
}
}
return (name) {
final subject = name.toLowerCase();
if (exact.contains(subject)) {
return true;
}
for (final pattern in globs) {
if (matchesNamePattern(subject, pattern)) {
return true;
}
}
return false;
};
}