+/*
+ * Instantlauncher. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+ */
+
package eu.svjatoslav.instantlauncher.configuration;
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
public class FileAssociation implements Comparable<FileAssociation> {
- public String fileRegex;
public String command;
+ public String fileRegex;
public FileAssociation() {
}
public int compareTo(FileAssociation o) {
return fileRegex.compareTo(o.fileRegex);
}
+
+ public boolean matchesFile(File file) {
+ String absolutePath = file.getAbsolutePath();
+
+ Pattern pattern = Pattern.compile(fileRegex);
+ Matcher matcher = pattern.matcher(absolutePath);
+ return matcher.matches();
+ }
+
}