public class FilterFileSystem extends java.lang.Object implements FileSystem
FilterFileSystem itself simply
overrides all methods of FileSystem with versions that pass all
requests to the contained file system. Subclasses of FilterFileSystem may
further override some of these methods and may also provide additional
methods and fields.FileSystem.OpenState| Modifier and Type | Field and Description |
|---|---|
protected FileSystem |
m_fs
The file system to which operations are delegated.
|
| Constructor and Description |
|---|
FilterFileSystem(FileSystem fs)
Creates a new filter file system.
|
| Modifier and Type | Method and Description |
|---|---|
void |
chdir(java.lang.String path)
Changes the current directory.
|
void |
close()
Stops the interaction with the file system.
|
void |
delete(java.lang.String path)
Deletes a directory and all its contents.
|
long |
getSize(java.lang.String path)
Gets the size of a file.
|
boolean |
isDirectory(java.lang.String path)
Determines if the resource pointed to by a given path corresponds to a
directory.
|
boolean |
isFile(java.lang.String path)
Determines if the resource pointed to by a given path corresponds to a
file.
|
java.util.List<java.lang.String> |
ls()
Lists all the files and folders in the current directory.
|
java.util.List<java.lang.String> |
ls(java.lang.String path)
Lists all the files and folders in a given directory.
|
void |
mkdir(java.lang.String path)
Creates a directory if it does not exist.
|
void |
open()
Starts the interaction with the file system.
|
void |
popd()
Changes the current directory to the one before the last call to
FileSystem.chdir(String) or FileSystem.pushd(String). |
void |
pushd(java.lang.String path) |
java.lang.String |
pwd()
Retrieves the current working directory, relative to the root of the
file system.
|
java.io.InputStream |
readFrom(java.lang.String filename)
Reads data from a file.
|
void |
rmdir(java.lang.String path)
Deletes a directory and all its contents.
|
java.io.OutputStream |
writeTo(java.lang.String filename)
Writes data to a file.
|
protected final FileSystem m_fs
public FilterFileSystem(FileSystem fs)
fs - The file system to which operations are delegatedpublic void open()
throws FileSystemException
FileSystemFileSystemException if called before
this method.open in interface FileSystemFileSystemException - Thrown if the interaction with the file system
cannot be startedpublic long getSize(java.lang.String path)
throws FileSystemException
FileSystemgetSize in interface FileSystempath - The path corresponding to the fileFileSystemException - Thrown if the operation could not be performed
for some reasonpublic java.util.List<java.lang.String> ls()
throws FileSystemException
FileSystemls in interface FileSystemFileSystemException - Thrown if the operation could not be performed
for some reasonpublic java.util.List<java.lang.String> ls(java.lang.String path)
throws FileSystemException
FileSystemls in interface FileSystempath - The path from which to list filesFileSystemException - Thrown if the operation could not be performed
for some reasonpublic boolean isDirectory(java.lang.String path)
throws FileSystemException
FileSystemisDirectory in interface FileSystempath - The pathFileSystemException - Thrown if the operation could not be performed
for some reasonpublic boolean isFile(java.lang.String path)
throws FileSystemException
FileSystemisFile in interface FileSystempath - The pathFileSystemException - Thrown if the operation could not be performed
for some reasonpublic java.io.OutputStream writeTo(java.lang.String filename)
throws FileSystemException
FileSystemOutputStream to
which data can be printed. The data is guaranteed to be committed to the
file only when the print stream is closed. Whether data is written before
that moment depends on the actual file system implementation.writeTo in interface FileSystemfilename - The name of the file to which data is to be writtenFileSystemException - Thrown if the operation could not be performed
for some reasonpublic java.io.InputStream readFrom(java.lang.String filename)
throws FileSystemException
FileSystemInputStream from
which data can be read. Consumers of this input stream have the
responsibility to close the stream after usage.readFrom in interface FileSystemfilename - The name of the file to which data is to be writtenFileSystemException - Thrown if the operation could not be performed
for some reasonpublic void chdir(java.lang.String path)
throws FileSystemException
FileSystemchdir in interface FileSystempath - The directory to change to. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonpublic void pushd(java.lang.String path)
throws FileSystemException
pushd in interface FileSystempath - The directory to change to. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonpublic void popd()
throws FileSystemException
FileSystemFileSystem.chdir(String) or FileSystem.pushd(String).popd in interface FileSystemFileSystemException - Thrown if the operation could not be performed
for some reasonpublic void mkdir(java.lang.String path)
throws FileSystemException
FileSystemmkdir in interface FileSystempath - The directory to create. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonpublic void rmdir(java.lang.String path)
throws FileSystemException
FileSystemrmdir in interface FileSystempath - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonpublic void delete(java.lang.String path)
throws FileSystemException
FileSystemdelete in interface FileSystempath - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonpublic java.lang.String pwd()
throws FileSystemException
FileSystempwd in interface FileSystemFileSystemException - Thrown if the operation could not be performed
for some reasonpublic void close()
throws FileSystemException
FileSystemFileSystemException if called after
this method.close in interface FileSystemFileSystemException - Thrown if an error occurred while stopping the
interaction with the file systemCopyright © Sylvain HallĂ©. All Rights Reserved.