Major code base cleanup #12

Merged
TopchetoEU merged 35 commits from TopchetoEU/cleanup into master 2024-01-06 16:28:11 +00:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit 21534efd60 - Show all commits

View File

@ -1,8 +1,17 @@
package me.topchetoeu.jscript.filesystem;
import me.topchetoeu.jscript.engine.Extensions;
import me.topchetoeu.jscript.engine.values.Symbol;
public interface Filesystem {
public static final Symbol ENV_KEY = Symbol.get("Environment.fs");
String normalize(String... path);
File open(String path, Mode mode) throws FilesystemException;
void create(String path, EntryType type) throws FilesystemException;
FileStat stat(String path) throws FilesystemException;
public static Filesystem get(Extensions exts) {
return exts.get(ENV_KEY);
}
}

View File

@ -25,11 +25,8 @@ public class FilesystemLib {
@Native public static final int SEEK_END = 2;
private static Filesystem fs(Context ctx) {
var env = ctx.environment();
if (env != null) {
var fs = ctx.environment().filesystem;
var fs = Filesystem.get(ctx);
if (fs != null) return fs;
}
throw EngineException.ofError("Current environment doesn't have a file system.");
}