Class TempFileSystem

java.lang.Object
com.aoapps.io.filesystems.TempFileSystem
All Implemented Interfaces:
FileSystem

public class TempFileSystem extends Object implements FileSystem
A temporary file system stored in the Java heap.
Author:
AO Industries, Inc.
  • Field Details

  • Constructor Details

    • TempFileSystem

      public TempFileSystem()
      Creates a new temp filesystem.
  • Method Details

    • checkSubPath

      public void checkSubPath(Path parent, String name)
      Temporary file systems support all possible paths.
      Specified by:
      checkSubPath in interface FileSystem
      Parameters:
      name - The path to check, must be from this file system.
    • list

      Description copied from interface: FileSystem
      Lists the children of the given path in no specific order. It is possible that paths may be returned that no longer exist. It is also possible that new file system objects created after the beginning of iteration are not returned.
      Specified by:
      list in interface FileSystem
      Parameters:
      path - Must be from this file system.
      Returns:
      a read-only iterator of children
      Throws:
      NoSuchFileException - if the path does not exist
      NotDirectoryException - if the path is not a directory
    • delete

      public void delete(Path path)
      Description copied from interface: FileSystem
      Deletes the file system object at the given path.
      Specified by:
      delete in interface FileSystem
      Parameters:
      path - Must be from this file system.
    • size

      public long size(Path path)
      Description copied from interface: FileSystem
      Gets the size of the file system object at the given path.
      Specified by:
      size in interface FileSystem
      Parameters:
      path - Must be from this file system.
    • createFile

      public Path createFile(Path path)
      Description copied from interface: FileSystem
      Atomically creates an empty file (must not have already existed).
      Specified by:
      createFile in interface FileSystem
      Returns:
      returns the path
    • createDirectory

      public Path createDirectory(Path path)
      Description copied from interface: FileSystem
      Atomically creates a directory (must not have already existed).
      Specified by:
      createDirectory in interface FileSystem
      Returns:
      returns the path
    • lock

      public FileLock lock(Path path)
      Description copied from interface: FileSystem
      Locks a file in exclusive mode. File range and shared locks not currently supported. The lock must be closed to unlock, usually in a try/finally or try-with-resources block. The locks are not reentrant, attempting to obtain the lock from the same thread will result in deadlock.
      Specified by:
      lock in interface FileSystem
      See Also: