Advertisement
Derek1017

VFS

Jul 10th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | None | 0 0
  1. /**
  2.  * This file is part of the public ComputerCraft API - http://www.computercraft.info
  3.  * Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
  4.  * For help using the API, and posting your mods, visit the forums at computercraft.info.
  5.  */
  6.  
  7. package dan200.computercraft.api.filesystem;
  8.  
  9. import java.io.IOException;
  10. import java.io.OutputStream;
  11.  
  12. /**
  13.  * Represents a part of a virtual filesystem that can be mounted onto a computercraft using IComputerAccess.mount() or IComputerAccess.mountWritable(), that can also be written to.
  14.  * Ready made implementations of this interface can be created using ComputerCraftAPI.createSaveDirMount(), or you're free to implement it yourselves!
  15. * @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
  16. * @see dan200.computercraft.api.peripheral.IComputerAccess#mountWritable(String, dan200.computercraft.api.filesystem.IMount)
  17. * @see dan200.computercraft.api.filesystem.IMount
  18. */
  19. public interface IWritableMount extends IMount
  20. {
  21.     /**
  22.      * Creates a directory at a given path inside the virtual file system.
  23.      * @param path A file path in normalised format, relative to the mount location. ie: "programs/mynewprograms"
  24.      */
  25.     public void makeDirectory( String path ) throws IOException;
  26.  
  27.     /**
  28.      * Deletes a directory at a given path inside the virtual file system.
  29.      * @param path A file path in normalised format, relative to the mount location. ie: "programs/myoldprograms"
  30.      */
  31.     public void delete( String path ) throws IOException;
  32.  
  33.     /**
  34.      * Opens a file with a given path, and returns an outputstream for writing to it.
  35.      * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
  36.      * @return a stream for writing to
  37.      */
  38.     public OutputStream openForWrite( String path ) throws IOException;
  39.  
  40.     /**
  41.      * Opens a file with a given path, and returns an outputstream for appending to it.
  42.      * @param path A file path in normalised format, relative to the mount location. ie: "programs/myprogram"
  43.      * @return a stream for writing to
  44.      */
  45.     public OutputStream openForAppend( String path ) throws IOException;
  46.  
  47.     /**
  48.      * 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.
  49.      * @return The ammount of free space, in bytes.
  50.      */
  51.     public long getRemainingSpace() throws IOException;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement