Class FileSystem

java.lang.Object
com.blackrook.fs.FileSystem

public class FileSystem extends Object
This is a virtual file system layer for applications and other projects that resolve resources from virtual and nonvirtual file systems and archives.
Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • FileSystem

      public FileSystem()
      Creates and initializes a new FileSystem.
  • Method Details

    • addArchive

      public void addArchive(FSFileArchive fsfa)
      Adds an archive to the bottom of the search stack.
      Parameters:
      fsfa - the archive to add.
    • removeArchive

      public boolean removeArchive(FSFileArchive fsfa)
      Removes an archive from the search stack.
      Parameters:
      fsfa - the archive to remove.
      Returns:
      true if removed, false if not.
    • pushArchive

      public void pushArchive(FSFileArchive fsfa)
      Pushes an archive onto the search stack.
      Parameters:
      fsfa - the archive to push.
    • popArchive

      public FSFileArchive popArchive()
      Pops an archive off of the search stack.
      Returns:
      what used to be the topmost archive on the stack.
    • getFile

      public FSFile getFile(String path) throws IOException
      Retrieves a file from the system. Searches down the stack.
      Parameters:
      path - the file path.
      Returns:
      A reference to the file as an FSFile object, null if not found.
      Throws:
      IOException - if a read error occurs during the fetch.
    • getAllFileInstances

      public FSFile[] getAllFileInstances(String path) throws IOException
      Retrieves all of the instances of a file from the system. Searches down the stack.
      Parameters:
      path - the file path.
      Returns:
      A reference to the files as an FSFile array object. An empty array implies that no files were found.
      Throws:
      IOException - if a read error occurs during the fetch.
    • getAllFiles

      public FSFile[] getAllFiles() throws IOException
      Retrieves all of the recent instances of a file from the system. Searches down the stack.
      Returns:
      A reference to the files as an FSFile array object.
      Throws:
      IOException - if a read error occurs during the fetch.
    • getAllFiles

      public FSFile[] getAllFiles(FSFileFilter filter) throws IOException
      Retrieves all of the recent instances of the files within this system that pass the filter test as FSFile objects.
      Parameters:
      filter - the file filter to use.
      Returns:
      A reference to the files as an FSFile array object.
      Throws:
      IOException - if a read error occurs during the fetch.
    • getAllFilesInDir

      public FSFile[] getAllFilesInDir(String path) throws IOException
      Retrieves all of the recent instances of the files within this system as FSFile objects.
      Parameters:
      path - the file path. Must be a directory.
      Returns:
      A reference to the files as an FSFile array object.
      Throws:
      IOException - if a read error occurs during the fetch.
    • getAllFilesInDir

      public FSFile[] getAllFilesInDir(String path, FSFileFilter filter) throws IOException
      Retrieves all of the recent instances of the files within this system that pass the filter test as FSFile objects.
      Parameters:
      path - the file path. Must be a directory.
      filter - the file filter to use.
      Returns:
      A reference to the files as an FSFile array object.
      Throws:
      IOException - if a read error occurs during the fetch.
    • createFile

      public OutputStream createFile(String path) throws IOException
      Creates a file in this system using the name and path provided. The file is created off of the topmost archive that can create files.
      Parameters:
      path - the path if the file to create.
      Returns:
      an acceptable OutputStream for filling the file with data, or null if no stream can be made.
      Throws:
      IOException - if a read error occurs during the fetch.
      See Also: