Class FilePathDebug


public class FilePathDebug extends FilePathWrapper
A debugging file system that logs all operations.
  • Constructor Details

    • FilePathDebug

      public FilePathDebug()
  • Method Details

    • register

      public static FilePathDebug register()
      Register the file system.
      Returns:
      the instance
    • createDirectory

      public void createDirectory()
      Description copied from class: FilePath
      Create a directory (all required parent directories already exist).
      Overrides:
      createDirectory in class FilePathWrapper
    • createFile

      public boolean createFile()
      Description copied from class: FilePath
      Create a new file.
      Overrides:
      createFile in class FilePathWrapper
      Returns:
      true if creating was successful
    • 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
    • exists

      public boolean exists()
      Description copied from class: FilePath
      Checks if a file exists.
      Overrides:
      exists in class FilePathWrapper
      Returns:
      true if it exists
    • getName

      public String getName()
      Description copied from class: FilePath
      Get the file or directory name (the last element of the path).
      Overrides:
      getName in class FilePath
      Returns:
      the last element of the path
    • lastModified

      public long lastModified()
      Description copied from class: FilePath
      Get the last modified date of a file
      Overrides:
      lastModified in class FilePathWrapper
      Returns:
      the last modified date
    • getParent

      public FilePath getParent()
      Description copied from class: FilePath
      Get the parent directory of a file or directory.
      Overrides:
      getParent in class FilePathWrapper
      Returns:
      the parent directory name
    • isAbsolute

      public boolean isAbsolute()
      Description copied from class: FilePath
      Check if the file name includes a path.
      Overrides:
      isAbsolute in class FilePathWrapper
      Returns:
      if the file name is absolute
    • isDirectory

      public boolean isDirectory()
      Description copied from class: FilePath
      Check if it is a file or a directory.
      Overrides:
      isDirectory in class FilePathWrapper
      Returns:
      true if it is a directory
    • isRegularFile

      public boolean isRegularFile()
      Description copied from class: FilePath
      Check if it is a regular file.
      Overrides:
      isRegularFile in class FilePathWrapper
      Returns:
      true if it is a regular file
    • canWrite

      public boolean canWrite()
      Description copied from class: FilePath
      Check if the file is writable.
      Overrides:
      canWrite in class FilePathWrapper
      Returns:
      if the file is writable
    • setReadOnly

      public boolean setReadOnly()
      Description copied from class: FilePath
      Disable the ability to write.
      Overrides:
      setReadOnly in class FilePathWrapper
      Returns:
      true if the call was successful
    • size

      public long size()
      Description copied from class: FilePath
      Get the size of a file in bytes
      Overrides:
      size in class FilePathWrapper
      Returns:
      the size in bytes
    • newDirectoryStream

      public List<FilePath> newDirectoryStream()
      Description copied from class: FilePath
      List the files and directories in the given directory.
      Overrides:
      newDirectoryStream in class FilePathWrapper
      Returns:
      the list of fully qualified file names
    • toRealPath

      public FilePath toRealPath()
      Description copied from class: FilePath
      Normalize a file name.
      Overrides:
      toRealPath in class FilePathWrapper
      Returns:
      the normalized file name
    • newInputStream

      public InputStream newInputStream() throws IOException
      Description copied from class: FilePath
      Create an input stream to read from the file.
      Overrides:
      newInputStream in class FilePathWrapper
      Returns:
      the input stream
      Throws:
      IOException - If an I/O error occurs
    • 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 newName, boolean atomicReplace)
      Description copied from class: FilePath
      Rename a file if this is allowed.
      Overrides:
      moveTo in class FilePathWrapper
      Parameters:
      newName - 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
    • 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
    • setPowerOffCount

      public void setPowerOffCount(int count)
    • getPowerOffCount

      public int getPowerOffCount()
    • isTrace

      public boolean isTrace()
    • setTrace

      public void setTrace(boolean trace)
    • getScheme

      public String getScheme()
      Description copied from class: FilePath
      Get the scheme (prefix) for this file provider. This is similar to java.nio.file.spi.FileSystemProvider.getScheme.
      Specified by:
      getScheme in class FilePath
      Returns:
      the scheme