Class ResourceFileSystem

java.lang.Object
ch.epfl.cs107.play.io.ResourceFileSystem
All Implemented Interfaces:
FileSystem

public class ResourceFileSystem extends Object implements FileSystem
Read-only implementation of file system, using native resources bundled with binaries.
  • Constructor Details

    • ResourceFileSystem

      public ResourceFileSystem(FileSystem fallback, ClassLoader loader)
      Creates a new resource file system using specified binaries.
      Parameters:
      fallback - (FileSystem): secondary file system used on error, not null
      loader - (ClassLoader): specific binary to use, not null
    • ResourceFileSystem

      public ResourceFileSystem(FileSystem fallback)
      Creates a new resource file system using core binaires.
      Parameters:
      fallback - (FileSystem): secondary file system used on error, not null
  • Method Details

    • read

      public InputStream read(String name) throws IOException
      Description copied from interface: FileSystem
      Open an existing file for read.
      Specified by:
      read in interface FileSystem
      Parameters:
      name - (String): unique identifier, not null
      Returns:
      (InputStream): content stream, not null
      Throws:
      IOException - if file cannot be open for read
    • write

      public OutputStream write(String name) throws IOException
      Description copied from interface: FileSystem
      Open file for write, previous content overwritten if any.
      Specified by:
      write in interface FileSystem
      Parameters:
      name - (String): unique identifier, not null
      Returns:
      (InputStream): content stream, not null
      Throws:
      IOException - if file cannot be open for write