mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-09-27 21:12:35 +02:00
Add RegEx to File Selection
This commit is contained in:
parent
9d01f46c16
commit
3fc249cf07
@ -50,12 +50,32 @@ public class ReplacementScanner {
|
|||||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||||
throw new IllegalStateException("Cannot access zipsearch()", e);
|
throw new IllegalStateException("Cannot access zipsearch()", e);
|
||||||
}
|
}
|
||||||
|
if (files.size() <= 0 || whitelist.length <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean csfs = false;
|
||||||
|
{
|
||||||
|
long stamp = Math.round(Math.random() * 100000);
|
||||||
|
File test1 = new File(dir, '.' + stamp + ".ss_fsc");
|
||||||
|
File test2 = new File(dir, '.' + stamp + ".SS_FSC");
|
||||||
|
|
||||||
|
test1.createNewFile();
|
||||||
|
if (test2.createNewFile()) {
|
||||||
|
csfs = true;
|
||||||
|
test2.delete();
|
||||||
|
}
|
||||||
|
test1.delete();
|
||||||
|
}
|
||||||
|
|
||||||
LinkedHashMap<Pattern, Boolean> rules = new LinkedHashMap<Pattern, Boolean>();
|
LinkedHashMap<Pattern, Boolean> rules = new LinkedHashMap<Pattern, Boolean>();
|
||||||
for (String entry : whitelist) {
|
for (String entry : whitelist) {
|
||||||
boolean mode = !entry.startsWith("!");
|
boolean mode = !entry.startsWith("!");
|
||||||
if (!mode) entry = entry.substring(1);
|
if (!mode) entry = entry.substring(1);
|
||||||
if (entry.startsWith(".")) entry = entry.substring(1);
|
|
||||||
|
String pattern;
|
||||||
|
if (!entry.startsWith("%")) {
|
||||||
|
if (entry.startsWith("./"))
|
||||||
|
entry = entry.substring(1);
|
||||||
|
|
||||||
StringBuilder rule = new StringBuilder();
|
StringBuilder rule = new StringBuilder();
|
||||||
if (entry.startsWith("**")) {
|
if (entry.startsWith("**")) {
|
||||||
@ -113,7 +133,13 @@ public class ReplacementScanner {
|
|||||||
if (greedyEnding)
|
if (greedyEnding)
|
||||||
rule.append(".*");
|
rule.append(".*");
|
||||||
rule.append("$");
|
rule.append("$");
|
||||||
rules.put(Pattern.compile(rule.toString()), mode);
|
pattern = rule.toString();
|
||||||
|
} else {
|
||||||
|
pattern = entry.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (csfs) rules.put(Pattern.compile(pattern), mode);
|
||||||
|
else rules.put(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
|
@ -50,12 +50,32 @@ public class ReplacementScanner {
|
|||||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||||
throw new IllegalStateException("Cannot access zipsearch()", e);
|
throw new IllegalStateException("Cannot access zipsearch()", e);
|
||||||
}
|
}
|
||||||
|
if (files.size() <= 0 || whitelist.length <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
boolean csfs = false;
|
||||||
|
{
|
||||||
|
long stamp = Math.round(Math.random() * 100000);
|
||||||
|
File test1 = new File(dir, '.' + stamp + ".ss_fsc");
|
||||||
|
File test2 = new File(dir, '.' + stamp + ".SS_FSC");
|
||||||
|
|
||||||
|
test1.createNewFile();
|
||||||
|
if (test2.createNewFile()) {
|
||||||
|
csfs = true;
|
||||||
|
test2.delete();
|
||||||
|
}
|
||||||
|
test1.delete();
|
||||||
|
}
|
||||||
|
|
||||||
LinkedHashMap<Pattern, Boolean> rules = new LinkedHashMap<Pattern, Boolean>();
|
LinkedHashMap<Pattern, Boolean> rules = new LinkedHashMap<Pattern, Boolean>();
|
||||||
for (String entry : whitelist) {
|
for (String entry : whitelist) {
|
||||||
boolean mode = !entry.startsWith("!");
|
boolean mode = !entry.startsWith("!");
|
||||||
if (!mode) entry = entry.substring(1);
|
if (!mode) entry = entry.substring(1);
|
||||||
if (entry.startsWith(".")) entry = entry.substring(1);
|
|
||||||
|
String pattern;
|
||||||
|
if (!entry.startsWith("%")) {
|
||||||
|
if (entry.startsWith("./"))
|
||||||
|
entry = entry.substring(1);
|
||||||
|
|
||||||
StringBuilder rule = new StringBuilder();
|
StringBuilder rule = new StringBuilder();
|
||||||
if (entry.startsWith("**")) {
|
if (entry.startsWith("**")) {
|
||||||
@ -113,7 +133,13 @@ public class ReplacementScanner {
|
|||||||
if (greedyEnding)
|
if (greedyEnding)
|
||||||
rule.append(".*");
|
rule.append(".*");
|
||||||
rule.append("$");
|
rule.append("$");
|
||||||
rules.put(Pattern.compile(rule.toString()), mode);
|
pattern = rule.toString();
|
||||||
|
} else {
|
||||||
|
pattern = entry.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (csfs) rules.put(Pattern.compile(pattern), mode);
|
||||||
|
else rules.put(Pattern.compile(pattern, Pattern.CASE_INSENSITIVE), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String file : files) {
|
for (String file : files) {
|
||||||
|
Loading…
Reference in New Issue
Block a user