Package com.google.common.jimfs
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 AttributeService
private final HeapDisk
private final FileFactory
private final Lock
private final FileSystemState
private final com.google.common.collect.ImmutableSet
<Feature> private final FileTree
private 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) File
copyWithoutContent
(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, ornull
if the view type is not supported.<V extends FileStoreAttributeView>
VgetFileStoreAttributeView
(Class<V> type) (package private) @Nullable Directory
Returns the root directory with the given name ornull
if no such directory exists.(package private) com.google.common.collect.ImmutableSortedSet
<Name> Returns the names of the root directories in this store.long
long
long
boolean
(package private) DirectoryEntry
lookUp
(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) Lock
readLock()
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) void
setAttribute
(File file, String attribute, Object value) Sets the given attribute to the given value for the given file.(package private) void
setInitialAttributes
(File file, 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
<String> 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
(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) Lock
Returns the write lock for this store.Methods inherited from class java.nio.file.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
Returns the root directory with the given name ornull
if no such directory exists. -
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, ornull
if the view type is not supported. -
readAttributes
Returns a map containing the attributes described by the given string mapped to their values. -
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
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
-
type
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnly
in classFileStore
-
getTotalSpace
- Specified by:
getTotalSpace
in classFileStore
- Throws:
IOException
-
getUsableSpace
- Specified by:
getUsableSpace
in classFileStore
- Throws:
IOException
-
getUnallocatedSpace
- Specified by:
getUnallocatedSpace
in classFileStore
- Throws:
IOException
-
supportsFileAttributeView
- Specified by:
supportsFileAttributeView
in classFileStore
-
supportsFileAttributeView
- Specified by:
supportsFileAttributeView
in classFileStore
-
getFileStoreAttributeView
- Specified by:
getFileStoreAttributeView
in classFileStore
-
getAttribute
- Specified by:
getAttribute
in classFileStore
- Throws:
IOException
-