mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 10:05:58 +01:00
Improve file exclusion
This commit is contained in:
@@ -70,9 +70,18 @@ public class FileFilter {
|
||||
private boolean isExcluded(File pathName, Set<String> excludedDirs) {
|
||||
if (excludedDirs.contains(pathName.getPath())) return true;
|
||||
|
||||
// TODO improve partial matches and wildcard?
|
||||
String[] pathSplit = pathName.getPath().split("/");
|
||||
for (String excludedDir : excludedDirs) {
|
||||
if (pathName.getPath().startsWith(excludedDir)) return true;
|
||||
String[] excludeSplit = excludedDir.split("/");
|
||||
if (excludeSplit.length > pathSplit.length) continue;
|
||||
boolean matchingPaths = true;
|
||||
for (int i = 0; i < excludeSplit.length; i++) {
|
||||
if (!excludeSplit[i].equals(pathSplit[i])) {
|
||||
matchingPaths = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matchingPaths) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class InputConfig implements CommandLine.IVersionProvider {
|
||||
@Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern (default: \".*\")")
|
||||
private Pattern includePattern;
|
||||
@Option(names = {"-e", "--excluded"}, arity = "1..*",
|
||||
description = "Directories and files to be excluded (no wildcard)")
|
||||
description = "relative directories and files to be excluded (no wildcard)")
|
||||
private Set<String> excluded = new HashSet<>();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user