Interface WritableMount

All Superinterfaces:
Mount

public interface WritableMount extends Mount
Represents a part of a virtual filesystem that can be mounted onto a computer using IComputerAccess.mount(String, Mount) or IComputerAccess.mountWritable(String, WritableMount), that can also be written to.

Typically you will not need to implement this interface yourself, and can use the factory methods from the the main ComputerCraft API.

See Also:
  • Method Details

    • makeDirectory

      void makeDirectory(String path) throws IOException
      Creates a directory at a given path inside the virtual file system.
      Parameters:
      path - A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms".
      Throws:
      IOException - If the directory already exists or could not be created.
    • delete

      void delete(String path) throws IOException
      Deletes a directory at a given path inside the virtual file system. If the file does not exist, this method should do nothing.
      Parameters:
      path - A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms".
      Throws:
      IOException - If the file does not exist or could not be deleted.
    • rename

      void rename(String source, String dest) throws IOException
      Rename a file or directory, moving it from one path to another.

      The destination path should not exist. The parent of the destination should exist and be a directory. If source and destination are the same, this method should do nothing.

      Parameters:
      source - The source file or directory to move.
      dest - The destination path.
      Throws:
      IOException
    • openForWrite

      SeekableByteChannel openForWrite(String path) throws IOException
      Opens a file with a given path, and returns an OutputStream for writing to it.
      Parameters:
      path - A file path in normalised format, relative to the mount location. ie: "programs/myprogram".
      Returns:
      A stream for writing to.
      Throws:
      IOException - If the file could not be opened for writing.
    • openForAppend

      SeekableByteChannel openForAppend(String path) throws IOException
      Opens a file with a given path, and returns an OutputStream for appending to it.
      Parameters:
      path - A file path in normalised format, relative to the mount location. ie: "programs/myprogram".
      Returns:
      A stream for writing to.
      Throws:
      IOException - If the file could not be opened for writing.
    • getRemainingSpace

      long getRemainingSpace() throws IOException
      Get the amount of free space on the mount, in bytes. You should decrease this value as the user writes to the mount, and write operations should fail once it reaches zero.
      Returns:
      The amount of free space, in bytes.
      Throws:
      IOException - If the remaining space could not be computed.
    • getCapacity

      long getCapacity()
      Get the capacity of this mount. This should be equal to the size of all files/directories on this mount, minus the getRemainingSpace().
      Returns:
      The capacity of this mount, in bytes.
    • isReadOnly

      default boolean isReadOnly(String path) throws IOException
      Returns whether a file with a given path is read-only or not.
      Parameters:
      path - A file path in normalised format, relative to the mount location. ie: "programs/myprograms".
      Returns:
      If the file exists and is read-only.
      Throws:
      IOException - If an error occurs when checking whether the file is read-only.