@ParametersAreNonnullByDefault public final class ReadOnlyFileSystemDriver extends Object implements FileSystemDriver
FileSystemDriver composition implementation over another driver
for read only filesystems
This class will delegate all read only operations to the underlying driver
and will make all write operations throw a ReadOnlyFileSystemException.
| Constructor and Description |
|---|
ReadOnlyFileSystemDriver(FileSystemDriver delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
checkAccess(Path path,
AccessMode... modes)
Check access modes for a path on this filesystem
|
void |
close()
Closes this stream and releases any system resources associated
with it.
|
void |
copy(Path source,
Path target,
CopyOption... options)
Copy a file, or empty directory, from one path to another on this
filesystem
|
void |
createDirectory(Path dir,
FileAttribute<?>... attrs)
Create a new directory from a path on this filesystem
|
void |
delete(Path path)
Delete a file, or empty directory, matching a path on this filesystem
|
<V extends FileAttributeView> |
getFileAttributeView(Path path,
Class<V> type,
LinkOption... options)
Read an attribute view for a given path on this filesystem
|
FileStore |
getFileStore()
Get the
FileStore associated with this filesystem |
PathElementsFactory |
getPathElementsFactory()
Get the
PathElementsFactory associated with this filesystem |
PathMatcherProvider |
getPathMatcherProvider()
Get a
PathMatcher provider for this filesystem |
PathElements |
getRoot()
Get the root path elements for this filesystem
|
Set<String> |
getSupportedFileAttributeViews()
Get a non-modifiable set of file attribute views supported by this
filesystem
|
URI |
getUri()
Get the URI associated with this filesystem
|
UserPrincipalLookupService |
getUserPrincipalLookupService()
Get a user/group lookup service for this filesystem
|
boolean |
isHidden(Path path)
Tell whether a path is to be considered hidden by this filesystem
|
boolean |
isSameFile(Path path,
Path path2)
Tell whether two paths actually refer to the same resource on this
filesystem
|
void |
move(Path source,
Path target,
CopyOption... options)
Move a file, or empty directory, from one path to another on this
filesystem
|
SeekableByteChannel |
newByteChannel(Path path,
Set<? extends OpenOption> options,
FileAttribute<?>... attrs)
Obtain a new
SeekableByteChannel from a path for this filesystem |
DirectoryStream<Path> |
newDirectoryStream(Path dir,
DirectoryStream.Filter<? super Path> filter)
Create a new directory stream from a path for this filesystem
|
InputStream |
newInputStream(Path path,
OpenOption... options)
Obtain a new
InputStream from a path for this filesystem |
OutputStream |
newOutputStream(Path path,
OpenOption... options)
Obtain a new
OutputStream from a path for this filesystem |
WatchService |
newWatchService()
Get a file watch service for this filesystem
|
<A extends BasicFileAttributes> |
readAttributes(Path path,
Class<A> type,
LinkOption... options)
Read attributes from a path on this filesystem
|
Map<String,Object> |
readAttributes(Path path,
String attributes,
LinkOption... options)
Read a list of attributes from a path on this filesystem
|
void |
setAttribute(Path path,
String attribute,
Object value,
LinkOption... options)
Set an attribute for a path on this filesystem
|
public ReadOnlyFileSystemDriver(FileSystemDriver delegate)
@Nonnull public OutputStream newOutputStream(Path path, OpenOption... options) throws IOException
OutputStream from a path for this filesystemnewOutputStream in interface FileSystemDriverpath - the pathoptions - the set of open optionsIOException - filesystem level error, or plain I/O errorFileSystemProvider.newOutputStream(Path, OpenOption...)@Nonnull public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException
SeekableByteChannel from a path for this filesystem
Note that a SeekableByteChannel supports both reads and
writes.
newByteChannel in interface FileSystemDriverpath - the pathoptions - the set of open optionsattrs - the attributes to create the file with (if it does not
exist)IOException - filesystem level error, or a plain I/O errorFileSystemProvider.newByteChannel(Path, Set, FileAttribute[])public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
createDirectory in interface FileSystemDriverdir - the directory to createattrs - the attributes with which the directory should be createdIOException - filesystem level error, or a plain I/O errorFileSystemProvider.newDirectoryStream(Path, DirectoryStream.Filter)public void delete(Path path) throws IOException
delete in interface FileSystemDriverpath - the victimIOException - filesystem level error, or a plain I/O errorFileSystemProvider.delete(Path)public void copy(Path source, Path target, CopyOption... options) throws IOException
copy in interface FileSystemDriversource - the source pathtarget - the target pathoptions - the copy optionsIOException - filesystem level error, or a plain I/O errorFileSystemProvider.copy(Path, Path, CopyOption...)public void move(Path source, Path target, CopyOption... options) throws IOException
move in interface FileSystemDriversource - the source pathtarget - the target pathoptions - the copy optionsIOException - filesystem level error, or a plain I/O errorFileSystemProvider.move(Path, Path, CopyOption...)public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException
setAttribute in interface FileSystemDriverpath - the victimattribute - the name of the attribute to setvalue - the value to setoptions - the link optionsIOException - filesystem level error, or a plain I/O errorIllegalArgumentException - malformed attribute, or the specified
attribute does not existUnsupportedOperationException - the attribute to set is not
supported by this filesystemClassCastException - attribute value is of the wrong class for the
specified attributeFiles.setAttribute(Path, String, Object, LinkOption...),
FileSystemProvider.setAttribute(Path, String, Object, LinkOption...)@Nonnull public URI getUri()
getUri in interface FileSystemDriver@Nonnull public PathElementsFactory getPathElementsFactory()
PathElementsFactory associated with this filesystemgetPathElementsFactory in interface FileSystemDriver@Nonnull public PathElements getRoot()
Typically, for Unix-like systems, this will be /.
getRoot in interface FileSystemDriverPathElements representing the root of the hierarchyFileSystem.getRootDirectories()@Nonnull public FileStore getFileStore()
FileStore associated with this filesystemgetFileStore in interface FileSystemDriverFileStoreFileStoreBase@Nonnull public Set<String> getSupportedFileAttributeViews()
This set (and therefore all implemented filesystems) must at least
contain "basic".
getSupportedFileAttributeViews in interface FileSystemDriverFileSystem.supportedFileAttributeViews()@Nonnull public PathMatcherProvider getPathMatcherProvider()
PathMatcher provider for this filesystemgetPathMatcherProvider in interface FileSystemDriverFileSystem.getPathMatcher(String),
com.github.fge.filesystem.path.matchers@Nonnull public UserPrincipalLookupService getUserPrincipalLookupService()
getUserPrincipalLookupService in interface FileSystemDriverFileSystem.getUserPrincipalLookupService()@Nonnull public WatchService newWatchService()
newWatchService in interface FileSystemDriverFileSystem.newWatchService()@Nonnull public InputStream newInputStream(Path path, OpenOption... options) throws IOException
InputStream from a path for this filesystemnewInputStream in interface FileSystemDriverpath - the pathoptions - the set of open optionsIOException - filesystem level error, or plain I/O errorFileSystemProvider.newInputStream(Path, OpenOption...)@Nonnull public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException
newDirectoryStream in interface FileSystemDriverdir - the directoryfilter - a directory entry filterIOException - filesystem level error, or a plain I/O errorFileSystemProvider.newDirectoryStream(Path, DirectoryStream.Filter)public boolean isSameFile(Path path, Path path2) throws IOException
Note that this DOES NOT apply to symbolic links, if the filesystem
supports them; that is, if path is a symlink to path2,
they are not the same file. Also, in spite of the method name,
this method can be called on paths which are not regular files but
directories, symlinks or others.
Two paths which are equal are always the
same.
isSameFile in interface FileSystemDriverpath - the first pathpath2 - the second pathIOException - filesystem level error, or a plain I/O errorFileSystemProvider.isSameFile(Path, Path)public boolean isHidden(Path path) throws IOException
Typically, on Unix systems, it means the last name element of the path
starts with a dot (".").
isHidden in interface FileSystemDriverpath - the path to testIOException - filesystem level error, or a plain I/O errorFileSystemProvider.isHidden(Path)public void checkAccess(Path path, AccessMode... modes) throws IOException
If no modes are provided to check for, this simply checks for the existence of the path.
checkAccess in interface FileSystemDriverpath - the path to checkmodes - the modes to check for, if anyIOException - filesystem level error, or a plain I/O errorFileSystemProvider.checkAccess(Path, AccessMode...)@Nullable public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options)
getFileAttributeView in interface FileSystemDriverV - type parameter of the attribute view classpath - the path to read attributes fromtype - the class of attribute view to returnoptions - the link optionsnull if this view is not supportedFileSystemProvider.getFileAttributeView(Path, Class, LinkOption...)public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
readAttributes in interface FileSystemDriverA - parameter type for the attributs classpath - the path to read attributes fromtype - the class of attributes to readoptions - the link optionsIOException - filesystem level error, or a plain I/O errorUnsupportedOperationException - attribute type not supportedFileSystemProvider.readAttributes(Path, Class, LinkOption...)public Map<String,Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException
readAttributes in interface FileSystemDriverpath - the path to read attributes fromattributes - the list of attributes to readoptions - the link optionsIOException - filesystem level error, or a plain I/O errorIllegalArgumentException - malformed attributes string; or a
specified attribute does not existUnsupportedOperationException - one or more attribute(s) is/are not
supportedFiles.readAttributes(Path, String, LinkOption...),
FileSystemProvider.readAttributes(Path, String, LinkOption...)public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOException - if an I/O error occurs