dan200.computer.api
Interface IWritableMount

All Superinterfaces:
IMount

public interface IWritableMount
extends IMount

Represents a part of a virtual filesystem that can be mounted onto a computer using IComputerAccess.mount() or IComputerAccess.mountWritable(), that can also be written to. Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount(), or you're free to implement it yourselves!

See Also:
ComputerCraftAPI#createSaveDirMount(World, String), IComputerAccess#mountWritable(String, IMount), IMount

Method Summary
 void delete(java.lang.String path)
          Deletes a directory at a given path inside the virtual file system.
 long getRemainingSpace()
          Get the ammount of free space on the mount, in bytes.
 void makeDirectory(java.lang.String path)
          Creates a directory at a given path inside the virtual file system.
 java.io.OutputStream openForAppend(java.lang.String path)
          Opens a file with a given path, and returns an outputstream for appending to it.
 java.io.OutputStream openForWrite(java.lang.String path)
          Opens a file with a given path, and returns an outputstream for writing to it.
 
Methods inherited from interface dan200.computer.api.IMount
exists, getSize, isDirectory, list, openForRead
 

Method Detail

makeDirectory

void makeDirectory(java.lang.String path)
                   throws java.io.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:
java.io.IOException

delete

void delete(java.lang.String path)
            throws java.io.IOException
Deletes 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/myoldprograms"
Throws:
java.io.IOException

openForWrite

java.io.OutputStream openForWrite(java.lang.String path)
                                  throws java.io.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:
java.io.IOException

openForAppend

java.io.OutputStream openForAppend(java.lang.String path)
                                   throws java.io.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:
java.io.IOException

getRemainingSpace

long getRemainingSpace()
                       throws java.io.IOException
Get the ammount 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 ammount of free space, in bytes.
Throws:
java.io.IOException