Class JimfsFileStore
java.lang.Object
java.nio.file.FileStore
com.google.common.jimfs.JimfsFileStore
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final AttributeServiceprivate final HeapDiskprivate final FileFactoryprivate final Lockprivate final FileSystemStateprivate final com.google.common.collect.ImmutableSet<Feature> private final FileTreeprivate final Lock -
Constructor Summary
ConstructorsConstructorDescriptionJimfsFileStore(FileTree tree, FileFactory factory, HeapDisk disk, AttributeService attributes, com.google.common.collect.ImmutableSet<Feature> supportedFeatures, FileSystemState state) -
Method Summary
Modifier and TypeMethodDescription(package private) FilecopyWithoutContent(File file, AttributeCopyOption attributeCopyOption) Creates a copy of the given file, copying its attributes as well according to the givenattributeCopyOption.(package private) com.google.common.base.Supplier<Directory> Returns a supplier that creates a new directory.getAttribute(String attribute) (package private) <V extends FileAttributeView>
@Nullable VgetFileAttributeView(FileLookup lookup, Class<V> type) Returns an attribute view of the given type for the given file lookup callback, ornullif the view type is not supported.<V extends FileStoreAttributeView>
VgetFileStoreAttributeView(Class<V> type) (package private) @Nullable DirectoryReturns the root directory with the given name ornullif no such directory exists.(package private) com.google.common.collect.ImmutableSortedSet<Name> Returns the names of the root directories in this store.longlonglongboolean(package private) DirectoryEntrylookUp(File workingDirectory, JimfsPath path, Set<? super LinkOption> options) Looks up the file at the given path using the given link options.name()(package private) <A extends BasicFileAttributes>
AreadAttributes(File file, Class<A> type) Returns attributes of the given file as an object of the given type.readAttributes(File file, String attributes) Returns a map containing the attributes described by the given string mapped to their values.(package private) LockreadLock()Returns the read lock for this store.(package private) com.google.common.base.Supplier<RegularFile> Returns a supplier that creates a new regular file.(package private) voidsetAttribute(File file, String attribute, Object value) Sets the given attribute to the given value for the given file.(package private) voidsetInitialAttributes(File file, FileAttribute<?>... attrs) Sets initial attributes on the given file.(package private) FileSystemStatestate()Returns the file system state object.(package private) com.google.common.collect.ImmutableSet<String> Returns the file attribute views supported by this store.(package private) booleansupportsFeature(Feature feature) Returns whether or not the given feature is supported by this file store.booleansupportsFileAttributeView(Class<? extends FileAttributeView> type) boolean(package private) com.google.common.base.Supplier<SymbolicLink> symbolicLinkCreator(JimfsPath target) Returns a supplier that creates a new symbolic link with the given target.type()(package private) LockReturns the write lock for this store.Methods inherited from class FileStore
getBlockSize
-
Field Details
-
tree
-
disk
-
attributes
-
factory
-
supportedFeatures
-
state
-
readLock
-
writeLock
-
-
Constructor Details
-
JimfsFileStore
public JimfsFileStore(FileTree tree, FileFactory factory, HeapDisk disk, AttributeService attributes, com.google.common.collect.ImmutableSet<Feature> supportedFeatures, FileSystemState state)
-
-
Method Details
-
state
FileSystemState 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
-
supportsFeature
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
Returns a supplier that creates a new symbolic link with the given target. -
copyWithoutContent
Creates a copy of the given file, copying its attributes as well according to the givenattributeCopyOption.- Throws:
IOException
-
setInitialAttributes
Sets initial attributes on the given file. Sets default attributes first, then attempts to set the given user-provided attributes. -
getFileAttributeView
Returns an attribute view of the given type for the given file lookup callback, ornullif the view type is not supported. -
readAttributes
-
readAttributes
Returns attributes of the given file as an object of the given type.- Throws:
UnsupportedOperationException- if the given attributes type is not supported
-
setAttribute
-
supportedFileAttributeViews
com.google.common.collect.ImmutableSet<String> supportedFileAttributeViews()Returns the file attribute views supported by this store. -
name
-
type
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnlyin classFileStore
-
getTotalSpace
- Specified by:
getTotalSpacein classFileStore- Throws:
IOException
-
getUsableSpace
- Specified by:
getUsableSpacein classFileStore- Throws:
IOException
-
getUnallocatedSpace
- Specified by:
getUnallocatedSpacein classFileStore- Throws:
IOException
-
supportsFileAttributeView
- Specified by:
supportsFileAttributeViewin classFileStore
-
supportsFileAttributeView
- Specified by:
supportsFileAttributeViewin classFileStore
-
getFileStoreAttributeView
- Specified by:
getFileStoreAttributeViewin classFileStore
-
getAttribute
- Specified by:
getAttributein classFileStore- Throws:
IOException
-