2013-07-22 07:05:40 +02:00
|
|
|
/**
|
|
|
|
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
|
|
|
* Copyright Daniel Ratcliffe, 2011-2013. This API may be redistributed unmodified and in full only.
|
|
|
|
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computer.api;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
2013-10-12 12:12:59 +02:00
|
|
|
|
|
|
|
import net.minecraft.world.World;
|
2013-07-22 07:05:40 +02:00
|
|
|
|
|
|
|
/**
|
2013-10-12 12:12:59 +02:00
|
|
|
* 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!
|
|
|
|
*
|
2013-07-22 07:05:40 +02:00
|
|
|
* @see ComputerCraftAPI#createSaveDirMount(World, String)
|
|
|
|
* @see IComputerAccess#mountWritable(String, IMount)
|
|
|
|
* @see IMount
|
|
|
|
*/
|
|
|
|
public interface IWritableMount extends IMount
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Creates a directory at a given path inside the virtual file system.
|
2013-10-12 12:12:59 +02:00
|
|
|
*
|
|
|
|
* @param path A file path in normalised format, relative to the mount location. ie:
|
|
|
|
* "programs/mynewprograms"
|
2013-07-22 07:05:40 +02:00
|
|
|
*/
|
2013-10-12 12:12:59 +02:00
|
|
|
public void makeDirectory(String path) throws IOException;
|
2013-07-22 07:05:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Deletes a directory at a given path inside the virtual file system.
|
2013-10-12 12:12:59 +02:00
|
|
|
*
|
|
|
|
* @param path A file path in normalised format, relative to the mount location. ie:
|
|
|
|
* "programs/myoldprograms"
|
2013-07-22 07:05:40 +02:00
|
|
|
*/
|
2013-10-12 12:12:59 +02:00
|
|
|
public void delete(String path) throws IOException;
|
2013-07-22 07:05:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a file with a given path, and returns an outputstream for writing to it.
|
2013-10-12 12:12:59 +02:00
|
|
|
*
|
|
|
|
* @param path A file path in normalised format, relative to the mount location. ie:
|
|
|
|
* "programs/myprogram"
|
2013-07-22 07:05:40 +02:00
|
|
|
* @return a stream for writing to
|
|
|
|
*/
|
2013-10-12 12:12:59 +02:00
|
|
|
public OutputStream openForWrite(String path) throws IOException;
|
2013-07-22 07:05:40 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens a file with a given path, and returns an outputstream for appending to it.
|
2013-10-12 12:12:59 +02:00
|
|
|
*
|
|
|
|
* @param path A file path in normalised format, relative to the mount location. ie:
|
|
|
|
* "programs/myprogram"
|
2013-07-22 07:05:40 +02:00
|
|
|
* @return a stream for writing to
|
|
|
|
*/
|
2013-10-12 12:12:59 +02:00
|
|
|
public OutputStream openForAppend(String path) throws IOException;
|
2013-07-22 07:05:40 +02:00
|
|
|
|
|
|
|
/**
|
2013-10-12 12:12:59 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2013-07-22 07:05:40 +02:00
|
|
|
* @return The ammount of free space, in bytes.
|
|
|
|
*/
|
|
|
|
public long getRemainingSpace() throws IOException;
|
|
|
|
}
|