Class FilePathRec


public class FilePathRec extends FilePathWrapper
A file system that records all write operations and can re-play them.
  • Field Details

    • INSTANCE

      private static final FilePathRec INSTANCE
    • recorder

      private static Recorder recorder
    • trace

      private boolean trace
  • Constructor Details

    • FilePathRec

      public FilePathRec()
  • Method Details

    • register

      public static void register()
      Register the file system.
    • setRecorder

      public static void setRecorder(Recorder recorder)
      Set the recorder class.
      Parameters:
      recorder - the recorder
    • createFile

      public boolean createFile()
      Description copied from class: FilePath
      Create a new file.
      Overrides:
      createFile in class FilePathWrapper
      Returns:
      true if creating was successful
    • createTempFile

      public FilePath createTempFile(String suffix, boolean inTempDir) throws IOException
      Description copied from class: FilePath
      Create a new temporary file.
      Overrides:
      createTempFile in class FilePathWrapper
      Parameters:
      suffix - the suffix
      inTempDir - if the file should be stored in the temporary directory
      Returns:
      the name of the created file
      Throws:
      IOException - on failure
    • delete

      public void delete()
      Description copied from class: FilePath
      Delete a file or directory if it exists. Directories may only be deleted if they are empty.
      Overrides:
      delete in class FilePathWrapper
    • open

      public FileChannel open(String mode) throws IOException
      Description copied from class: FilePath
      Open a random access file object.
      Overrides:
      open in class FilePathWrapper
      Parameters:
      mode - the access mode. Supported are r, rw, rws, rwd
      Returns:
      the file object
      Throws:
      IOException - If an I/O error occurs
    • newOutputStream

      public OutputStream newOutputStream(boolean append) throws IOException
      Description copied from class: FilePath
      Create an output stream to write into the file.
      Overrides:
      newOutputStream in class FilePathWrapper
      Parameters:
      append - if true, the file will grow, if false, the file will be truncated first
      Returns:
      the output stream
      Throws:
      IOException - If an I/O error occurs
    • moveTo

      public void moveTo(FilePath newPath, boolean atomicReplace)
      Description copied from class: FilePath
      Rename a file if this is allowed.
      Overrides:
      moveTo in class FilePathWrapper
      Parameters:
      newPath - the new fully qualified file name
      atomicReplace - whether the move should be atomic, and the target file should be replaced if it exists and replacing is possible
    • isTrace

      public boolean isTrace()
    • setTrace

      public void setTrace(boolean trace)
    • log

      void log(int op, String fileName)
      Log the operation.
      Parameters:
      op - the operation
      fileName - the file name(s)
    • log

      void log(int op, String fileName, byte[] data, long x)
      Log the operation.
      Parameters:
      op - the operation
      fileName - the file name
      data - the data or null
      x - the value or 0
    • getScheme

      public String getScheme()
      Get the prefix for this file system.
      Specified by:
      getScheme in class FilePath
      Returns:
      the prefix