Class JimfsFileStore


  • final class JimfsFileStore
    extends java.nio.file.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.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) File copyWithoutContent​(File file, AttributeCopyOption attributeCopyOption)
      Creates a copy of the given file, copying its attributes as well according to the given attributeCopyOption.
      (package private) com.google.common.base.Supplier<Directory> directoryCreator()
      Returns a supplier that creates a new directory.
      java.lang.Object getAttribute​(java.lang.String attribute)  
      (package private) <V extends java.nio.file.attribute.FileAttributeView>
      @Nullable V
      getFileAttributeView​(FileLookup lookup, java.lang.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.
      <V extends java.nio.file.attribute.FileStoreAttributeView>
      V
      getFileStoreAttributeView​(java.lang.Class<V> type)  
      (package private) @Nullable Directory getRoot​(Name name)
      Returns the root directory with the given name or null if no such directory exists.
      (package private) com.google.common.collect.ImmutableSortedSet<Name> getRootDirectoryNames()
      Returns the names of the root directories in this store.
      long getTotalSpace()  
      long getUnallocatedSpace()  
      long getUsableSpace()  
      boolean isReadOnly()  
      (package private) DirectoryEntry lookUp​(File workingDirectory, JimfsPath path, java.util.Set<? super java.nio.file.LinkOption> options)
      Looks up the file at the given path using the given link options.
      java.lang.String name()  
      (package private) <A extends java.nio.file.attribute.BasicFileAttributes>
      A
      readAttributes​(File file, java.lang.Class<A> type)
      Returns attributes of the given file as an object of the given type.
      (package private) com.google.common.collect.ImmutableMap<java.lang.String,​java.lang.Object> readAttributes​(File file, java.lang.String attributes)
      Returns a map containing the attributes described by the given string mapped to their values.
      (package private) java.util.concurrent.locks.Lock readLock()
      Returns the read lock for this store.
      (package private) com.google.common.base.Supplier<RegularFile> regularFileCreator()
      Returns a supplier that creates a new regular file.
      (package private) void setAttribute​(File file, java.lang.String attribute, java.lang.Object value)
      Sets the given attribute to the given value for the given file.
      (package private) void setInitialAttributes​(File file, java.nio.file.attribute.FileAttribute<?>... attrs)
      Sets initial attributes on the given file.
      (package private) FileSystemState state()
      Returns the file system state object.
      (package private) com.google.common.collect.ImmutableSet<java.lang.String> supportedFileAttributeViews()
      Returns the file attribute views supported by this store.
      (package private) boolean supportsFeature​(Feature feature)
      Returns whether or not the given feature is supported by this file store.
      boolean supportsFileAttributeView​(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)  
      boolean supportsFileAttributeView​(java.lang.String name)  
      (package private) com.google.common.base.Supplier<SymbolicLink> symbolicLinkCreator​(JimfsPath target)
      Returns a supplier that creates a new symbolic link with the given target.
      java.lang.String type()  
      (package private) java.util.concurrent.locks.Lock writeLock()
      Returns the write lock for this store.
      • Methods inherited from class java.nio.file.FileStore

        getBlockSize
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • supportedFeatures

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

        private final java.util.concurrent.locks.Lock readLock
      • writeLock

        private final java.util.concurrent.locks.Lock writeLock
    • Method Detail

      • readLock

        java.util.concurrent.locks.Lock readLock()
        Returns the read lock for this store.
      • writeLock

        java.util.concurrent.locks.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,
                              java.util.Set<? super java.nio.file.LinkOption> options)
                       throws java.io.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:
        java.nio.file.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)
        java.io.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 java.io.IOException
        Creates a copy of the given file, copying its attributes as well according to the given attributeCopyOption.
        Throws:
        java.io.IOException
      • setInitialAttributes

        void setInitialAttributes​(File file,
                                  java.nio.file.attribute.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 java.nio.file.attribute.FileAttributeView> @Nullable V getFileAttributeView​(FileLookup lookup,
                                                                                               java.lang.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<java.lang.String,​java.lang.Object> readAttributes​(File file,
                                                                                                       java.lang.String attributes)
        Returns a map containing the attributes described by the given string mapped to their values.
      • readAttributes

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

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

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

        public java.lang.String name()
        Specified by:
        name in class java.nio.file.FileStore
      • type

        public java.lang.String type()
        Specified by:
        type in class java.nio.file.FileStore
      • isReadOnly

        public boolean isReadOnly()
        Specified by:
        isReadOnly in class java.nio.file.FileStore
      • getTotalSpace

        public long getTotalSpace()
                           throws java.io.IOException
        Specified by:
        getTotalSpace in class java.nio.file.FileStore
        Throws:
        java.io.IOException
      • getUsableSpace

        public long getUsableSpace()
                            throws java.io.IOException
        Specified by:
        getUsableSpace in class java.nio.file.FileStore
        Throws:
        java.io.IOException
      • getUnallocatedSpace

        public long getUnallocatedSpace()
                                 throws java.io.IOException
        Specified by:
        getUnallocatedSpace in class java.nio.file.FileStore
        Throws:
        java.io.IOException
      • supportsFileAttributeView

        public boolean supportsFileAttributeView​(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)
        Specified by:
        supportsFileAttributeView in class java.nio.file.FileStore
      • supportsFileAttributeView

        public boolean supportsFileAttributeView​(java.lang.String name)
        Specified by:
        supportsFileAttributeView in class java.nio.file.FileStore
      • getFileStoreAttributeView

        public <V extends java.nio.file.attribute.FileStoreAttributeView> V getFileStoreAttributeView​(java.lang.Class<V> type)
        Specified by:
        getFileStoreAttributeView in class java.nio.file.FileStore
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String attribute)
                                      throws java.io.IOException
        Specified by:
        getAttribute in class java.nio.file.FileStore
        Throws:
        java.io.IOException