public interface IMount
IComputerAccess.mount(String, IMount)
Ready made implementations of this interface can be created using
ComputerCraftAPI.createSaveDirMount(World, String, long)
or
ComputerCraftAPI.createResourceMount(Class, String, String)
, or you're free to implement it yourselves!Modifier and Type | Method and Description |
---|---|
boolean |
exists(java.lang.String path)
Returns whether a file with a given path exists or not.
|
long |
getSize(java.lang.String path)
Returns the size of a file with a given path, in bytes
|
boolean |
isDirectory(java.lang.String path)
Returns whether a file with a given path is a directory or not.
|
void |
list(java.lang.String path,
java.util.List<java.lang.String> contents)
Returns the file names of all the files in a directory.
|
default java.nio.channels.ReadableByteChannel |
openChannelForRead(java.lang.String path)
Opens a file with a given path, and returns an
ReadableByteChannel representing its contents. |
java.io.InputStream |
openForRead(java.lang.String path)
Deprecated.
Use
openChannelForRead(String) instead |
boolean exists(@Nonnull java.lang.String path) throws java.io.IOException
path
- A file path in normalised format, relative to the mount location. ie: "programs/myprogram"java.io.IOException
- If an error occurs when checking the existence of the file.boolean isDirectory(@Nonnull java.lang.String path) throws java.io.IOException
path
- A file path in normalised format, relative to the mount location. ie: "programs/myprograms".java.io.IOException
- If an error occurs when checking whether the file is a directory.void list(@Nonnull java.lang.String path, @Nonnull java.util.List<java.lang.String> contents) throws java.io.IOException
path
- A file path in normalised format, relative to the mount location. ie: "programs/myprograms".contents
- A list of strings. Add all the file names to this list.java.io.IOException
- If the file was not a directory, or could not be listed.long getSize(@Nonnull java.lang.String path) throws java.io.IOException
path
- A file path in normalised format, relative to the mount location. ie: "programs/myprogram".java.io.IOException
- If the file does not exist, or its size could not be determined.@Nonnull @Deprecated java.io.InputStream openForRead(@Nonnull java.lang.String path) throws java.io.IOException
openChannelForRead(String)
insteadInputStream
representing its contents.path
- A file path in normalised format, relative to the mount location. ie: "programs/myprogram".java.io.IOException
- If the file does not exist, or could not be opened.@Nonnull default java.nio.channels.ReadableByteChannel openChannelForRead(@Nonnull java.lang.String path) throws java.io.IOException
ReadableByteChannel
representing its contents.path
- A file path in normalised format, relative to the mount location. ie: "programs/myprogram".SeekableByteChannel
, one will be able to seek to arbitrary positions when using binary
mode.java.io.IOException
- If the file does not exist, or could not be opened.