Package com.google.common.jimfs
Class JimfsFileStore
- java.lang.Object
-
- java.nio.file.FileStore
-
- com.google.common.jimfs.JimfsFileStore
-
final class JimfsFileStore extends java.nio.file.FileStoreFileStoreimplementation which provides methods for file creation, lookup and attribute handling.Most of these methods are actually implemented in another class:
FileTreefor lookup,FileFactoryfor creating and copying files andAttributeServicefor attribute handling. This class merely provides a single API through which to access the functionality of those classes.
-
-
Field Summary
Fields Modifier and Type Field Description private AttributeServiceattributesprivate HeapDiskdiskprivate FileFactoryfactoryprivate java.util.concurrent.locks.LockreadLockprivate FileSystemStatestateprivate com.google.common.collect.ImmutableSet<Feature>supportedFeaturesprivate FileTreetreeprivate java.util.concurrent.locks.LockwriteLock
-
Constructor Summary
Constructors Constructor Description JimfsFileStore(FileTree tree, FileFactory factory, HeapDisk disk, AttributeService attributes, com.google.common.collect.ImmutableSet<Feature> supportedFeatures, FileSystemState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (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>directoryCreator()Returns a supplier that creates a new directory.java.lang.ObjectgetAttribute(java.lang.String attribute)(package private) <V extends java.nio.file.attribute.FileAttributeView>
@Nullable VgetFileAttributeView(FileLookup lookup, java.lang.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 java.nio.file.attribute.FileStoreAttributeView>
VgetFileStoreAttributeView(java.lang.Class<V> type)(package private) @Nullable DirectorygetRoot(Name name)Returns the root directory with the given name ornullif no such directory exists.(package private) com.google.common.collect.ImmutableSortedSet<Name>getRootDirectoryNames()Returns the names of the root directories in this store.longgetTotalSpace()longgetUnallocatedSpace()longgetUsableSpace()booleanisReadOnly()(package private) DirectoryEntrylookUp(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.Stringname()(package private) <A extends java.nio.file.attribute.BasicFileAttributes>
AreadAttributes(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.LockreadLock()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) voidsetAttribute(File file, java.lang.String attribute, java.lang.Object value)Sets the given attribute to the given value for the given file.(package private) voidsetInitialAttributes(File file, java.nio.file.attribute.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<java.lang.String>supportedFileAttributeViews()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(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)booleansupportsFileAttributeView(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.Stringtype()(package private) java.util.concurrent.locks.LockwriteLock()Returns the write lock for this store.
-
-
-
Field Detail
-
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 java.util.concurrent.locks.Lock readLock
-
writeLock
private final java.util.concurrent.locks.Lock writeLock
-
-
Constructor Detail
-
JimfsFileStore
public JimfsFileStore(FileTree tree, FileFactory factory, HeapDisk disk, AttributeService attributes, com.google.common.collect.ImmutableSet<Feature> supportedFeatures, FileSystemState state)
-
-
Method Detail
-
state
FileSystemState state()
Returns the file system state object.
-
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 ornullif 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 givenattributeCopyOption.- 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, ornullif 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:
namein classjava.nio.file.FileStore
-
type
public java.lang.String type()
- Specified by:
typein classjava.nio.file.FileStore
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin classjava.nio.file.FileStore
-
getTotalSpace
public long getTotalSpace() throws java.io.IOException- Specified by:
getTotalSpacein classjava.nio.file.FileStore- Throws:
java.io.IOException
-
getUsableSpace
public long getUsableSpace() throws java.io.IOException- Specified by:
getUsableSpacein classjava.nio.file.FileStore- Throws:
java.io.IOException
-
getUnallocatedSpace
public long getUnallocatedSpace() throws java.io.IOException- Specified by:
getUnallocatedSpacein classjava.nio.file.FileStore- Throws:
java.io.IOException
-
supportsFileAttributeView
public boolean supportsFileAttributeView(java.lang.Class<? extends java.nio.file.attribute.FileAttributeView> type)
- Specified by:
supportsFileAttributeViewin classjava.nio.file.FileStore
-
supportsFileAttributeView
public boolean supportsFileAttributeView(java.lang.String name)
- Specified by:
supportsFileAttributeViewin classjava.nio.file.FileStore
-
getFileStoreAttributeView
public <V extends java.nio.file.attribute.FileStoreAttributeView> V getFileStoreAttributeView(java.lang.Class<V> type)
- Specified by:
getFileStoreAttributeViewin classjava.nio.file.FileStore
-
getAttribute
public java.lang.Object getAttribute(java.lang.String attribute) throws java.io.IOException- Specified by:
getAttributein classjava.nio.file.FileStore- Throws:
java.io.IOException
-
-