|
@@ -2,9 +2,11 @@ package org.openzen.zenscript.scriptingexample;
|
2
|
2
|
|
3
|
3
|
import java.io.File;
|
4
|
4
|
import java.io.IOException;
|
|
5
|
+import java.nio.file.Files;
|
|
6
|
+import java.nio.file.Path;
|
5
|
7
|
import java.util.HashMap;
|
6
|
8
|
import java.util.Map;
|
7
|
|
-import java.util.Optional;
|
|
9
|
+
|
8
|
10
|
import org.openzen.zencode.java.JavaNativeModule;
|
9
|
11
|
import org.openzen.zencode.java.ScriptingEngine;
|
10
|
12
|
import org.openzen.zencode.shared.CompileException;
|
|
@@ -41,10 +43,17 @@ public class Main {
|
41
|
43
|
scriptingEngine.registerNativeProvided(example);
|
42
|
44
|
|
43
|
45
|
File inputDirectory = new File("scripts");
|
44
|
|
- File[] inputFiles = Optional.ofNullable(inputDirectory.listFiles((dir, name) -> name.endsWith(".zs"))).orElseGet(() -> new File[0]);
|
45
|
|
- SourceFile[] sourceFiles = new SourceFile[inputFiles.length];
|
46
|
|
- for (int i = 0; i < inputFiles.length; i++)
|
47
|
|
- sourceFiles[i] = new FileSourceFile(inputFiles[i].getName(), inputFiles[i]);
|
|
46
|
+ final SourceFile[] sourceFiles = Files.walk(inputDirectory.getAbsoluteFile().toPath())
|
|
47
|
+ .map(Path::toFile)
|
|
48
|
+ .filter(File::isFile)
|
|
49
|
+ .filter(f -> f.getName().endsWith(".zs"))
|
|
50
|
+ .filter(f -> !f.getAbsolutePath().contains("nope"))
|
|
51
|
+ .map(f -> new FileSourceFile(f.getName(), f))
|
|
52
|
+ .toArray(SourceFile[]::new);
|
|
53
|
+ //File[] inputFiles = Optional.ofNullable(inputDirectory.listFiles((dir, name) -> name.endsWith(".zs"))).orElseGet(() -> new File[0]);
|
|
54
|
+ //SourceFile[] sourceFiles = new SourceFile[inputFiles.length];
|
|
55
|
+ //for (int i = 0; i < inputFiles.length; i++)
|
|
56
|
+ // sourceFiles[i] = new FileSourceFile(inputFiles[i].getName(), inputFiles[i]);
|
48
|
57
|
|
49
|
58
|
final PrefixedBracketParser parser = new PrefixedBracketParser(null);
|
50
|
59
|
BracketExpressionParser testParser = new SimpleBracketParser(scriptingEngine.registry, example.loadStaticMethod(Globals.class.getMethod("bracket", String.class)));
|