Interface WritableMount
- All Superinterfaces:
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.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deletes a directory at a given path inside the virtual file system.long
Get the capacity of this mount.long
Get the amount of free space on the mount, in bytes.default boolean
isReadOnly
(String path) Returns whether a file with a given path is read-only or not.void
makeDirectory
(String path) Creates a directory at a given path inside the virtual file system.openForAppend
(String path) Opens a file with a given path, and returns anOutputStream
for appending to it.openForWrite
(String path) Opens a file with a given path, and returns anOutputStream
for writing to it.void
Rename a file or directory, moving it from one path to another.Methods inherited from interface dan200.computercraft.api.filesystem.Mount
exists, getAttributes, getSize, isDirectory, list, openForRead
-
Method Details
-
makeDirectory
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
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
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
Opens a file with a given path, and returns anOutputStream
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
Opens a file with a given path, and returns anOutputStream
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
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 thegetRemainingSpace()
.- Returns:
- The capacity of this mount, in bytes.
-
isReadOnly
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.
-