Class JimfsFileStore

java.lang.Object
java.nio.file.FileStore
com.google.common.jimfs.JimfsFileStore

final class JimfsFileStore extends FileStore
FileStore implementation which provides methods for file creation, lookup and attribute handling.

Most of these methods are actually implemented in another class: FileTree for lookup, FileFactory for creating and copying files and AttributeService for attribute handling. This class merely provides a single API through which to access the functionality of those classes.

  • Field Details

    • tree

      private final FileTree tree
    • disk

      private final HeapDisk disk
    • attributes

      private final AttributeService attributes
    • factory

      private final FileFactory factory
    • supportedFeatures

      private final com.google.common.collect.ImmutableSet<Feature> supportedFeatures
    • state

      private final FileSystemState state
    • readLock

      private final Lock readLock
    • writeLock

      private final Lock writeLock
  • Constructor Details

  • Method Details

    • state

      Returns the file system state object.
    • readLock

      Lock readLock()
      Returns the read lock for this store.
    • writeLock

      Lock writeLock()
      Returns the write lock for this store.
    • getRootDirectoryNames

      com.google.common.collect.ImmutableSortedSet<Name> getRootDirectoryNames()
      Returns the names of the root directories in this store.
    • getRoot

      @Nullable Directory getRoot(Name name)
      Returns the root directory with the given name or null if no such directory exists.
    • supportsFeature

      boolean supportsFeature(Feature feature)
      Returns whether or not the given feature is supported by this file store.
    • lookUp

      DirectoryEntry lookUp(File workingDirectory, JimfsPath path, Set<? super LinkOption> options) throws IOException
      Looks up the file at the given path using the given link options. If the path is relative, the lookup is relative to the given working directory.
      Throws:
      NoSuchFileException - if an element of the path other than the final element does not resolve to a directory or symbolic link (e.g. it doesn't exist or is a regular file)
      IOException - if a symbolic link cycle is detected or the depth of symbolic link recursion otherwise exceeds a threshold
    • regularFileCreator

      com.google.common.base.Supplier<RegularFile> regularFileCreator()
      Returns a supplier that creates a new regular file.
    • directoryCreator

      com.google.common.base.Supplier<Directory> directoryCreator()
      Returns a supplier that creates a new directory.
    • symbolicLinkCreator

      com.google.common.base.Supplier<SymbolicLink> symbolicLinkCreator(JimfsPath target)
      Returns a supplier that creates a new symbolic link with the given target.
    • copyWithoutContent

      File copyWithoutContent(File file, AttributeCopyOption attributeCopyOption) throws IOException
      Creates a copy of the given file, copying its attributes as well according to the given attributeCopyOption.
      Throws:
      IOException
    • setInitialAttributes

      void setInitialAttributes(File file, FileAttribute<?>... attrs)
      Sets initial attributes on the given file. Sets default attributes first, then attempts to set the given user-provided attributes.
    • getFileAttributeView

      <V extends FileAttributeView> @Nullable V getFileAttributeView(FileLookup lookup, Class<V> type)
      Returns an attribute view of the given type for the given file lookup callback, or null if the view type is not supported.
    • readAttributes

      com.google.common.collect.ImmutableMap<String,Object> readAttributes(File file, String attributes)
      Returns a map containing the attributes described by the given string mapped to their values.
    • readAttributes

      <A extends BasicFileAttributes> A readAttributes(File file, Class<A> type)
      Returns attributes of the given file as an object of the given type.
      Throws:
      UnsupportedOperationException - if the given attributes type is not supported
    • setAttribute

      void setAttribute(File file, String attribute, Object value)
      Sets the given attribute to the given value for the given file.
    • supportedFileAttributeViews

      com.google.common.collect.ImmutableSet<String> supportedFileAttributeViews()
      Returns the file attribute views supported by this store.
    • name

      public String name()
      Specified by:
      name in class FileStore
    • type

      public String type()
      Specified by:
      type in class FileStore
    • isReadOnly

      public boolean isReadOnly()
      Specified by:
      isReadOnly in class FileStore
    • getTotalSpace

      public long getTotalSpace() throws IOException
      Specified by:
      getTotalSpace in class FileStore
      Throws:
      IOException
    • getUsableSpace

      public long getUsableSpace() throws IOException
      Specified by:
      getUsableSpace in class FileStore
      Throws:
      IOException
    • getUnallocatedSpace

      public long getUnallocatedSpace() throws IOException
      Specified by:
      getUnallocatedSpace in class FileStore
      Throws:
      IOException
    • supportsFileAttributeView

      public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type)
      Specified by:
      supportsFileAttributeView in class FileStore
    • supportsFileAttributeView

      public boolean supportsFileAttributeView(String name)
      Specified by:
      supportsFileAttributeView in class FileStore
    • getFileStoreAttributeView

      public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type)
      Specified by:
      getFileStoreAttributeView in class FileStore
    • getAttribute

      public Object getAttribute(String attribute) throws IOException
      Specified by:
      getAttribute in class FileStore
      Throws:
      IOException