Class SandboxedFileSystem

java.lang.Object
com.soulfiremc.server.script.SandboxedFileSystem
All Implemented Interfaces:
org.graalvm.polyglot.io.FileSystem

public class SandboxedFileSystem extends Object implements org.graalvm.polyglot.io.FileSystem
Sandboxed file system for scripts. Scripts can only access files within their own directory or subdirectories. The scheme is forced to be UNIX, and the root is the script's directory.
  • Constructor Details

    • SandboxedFileSystem

      public SandboxedFileSystem(Set<Path> writableDirs, Set<Path> readableDirs, Path defaultWorkingDir)
  • Method Details

    • parsePath

      public Path parsePath(URI uri)
      Specified by:
      parsePath in interface org.graalvm.polyglot.io.FileSystem
    • parsePath

      public Path parsePath(String path)
      Specified by:
      parsePath in interface org.graalvm.polyglot.io.FileSystem
    • checkAccess

      public void checkAccess(Path path, Set<? extends AccessMode> modes, LinkOption... linkOptions) throws IOException
      Specified by:
      checkAccess in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • createDirectory

      public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
      Specified by:
      createDirectory in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • delete

      public void delete(Path path) throws IOException
      Specified by:
      delete in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • newByteChannel

      public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
      Specified by:
      newByteChannel in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • newDirectoryStream

      public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
      Specified by:
      newDirectoryStream in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • toAbsolutePath

      public Path toAbsolutePath(Path path)
      Specified by:
      toAbsolutePath in interface org.graalvm.polyglot.io.FileSystem
    • toRealPath

      public Path toRealPath(Path path, LinkOption... linkOptions) throws IOException
      Specified by:
      toRealPath in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • readAttributes

      public Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
      Specified by:
      readAttributes in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • setAttribute

      public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
      Specified by:
      setAttribute in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • copy

      public void copy(Path source, Path target, CopyOption... options) throws IOException
      Specified by:
      copy in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • move

      public void move(Path source, Path target, CopyOption... options) throws IOException
      Specified by:
      move in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • createLink

      public void createLink(Path link, Path existing) throws IOException
      Specified by:
      createLink in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • createSymbolicLink

      public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException
      Specified by:
      createSymbolicLink in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • readSymbolicLink

      public Path readSymbolicLink(Path link) throws IOException
      Specified by:
      readSymbolicLink in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException
    • setCurrentWorkingDirectory

      public void setCurrentWorkingDirectory(Path currentWorkingDirectory)
      Specified by:
      setCurrentWorkingDirectory in interface org.graalvm.polyglot.io.FileSystem
    • getSeparator

      public String getSeparator()
      Specified by:
      getSeparator in interface org.graalvm.polyglot.io.FileSystem
    • getPathSeparator

      public String getPathSeparator()
      Specified by:
      getPathSeparator in interface org.graalvm.polyglot.io.FileSystem
    • getMimeType

      public String getMimeType(Path path)
      Specified by:
      getMimeType in interface org.graalvm.polyglot.io.FileSystem
    • getEncoding

      public Charset getEncoding(Path path)
      Specified by:
      getEncoding in interface org.graalvm.polyglot.io.FileSystem
    • getTempDirectory

      public Path getTempDirectory()
      Specified by:
      getTempDirectory in interface org.graalvm.polyglot.io.FileSystem
    • isSameFile

      public boolean isSameFile(Path path1, Path path2, LinkOption... options) throws IOException
      Specified by:
      isSameFile in interface org.graalvm.polyglot.io.FileSystem
      Throws:
      IOException