public class Chroot extends FilterFileSystem
FileSystem.OpenState| Modifier and Type | Field and Description |
|---|---|
protected FilePath |
m_root
The path in the underlying file system acting as the root of the current
file system.
|
m_fs| Constructor and Description |
|---|
Chroot(FileSystem fs,
java.lang.String root)
Creates a new chroot file system.
|
| Modifier and Type | Method and Description |
|---|---|
void |
chdir(java.lang.String path)
Changes the current directory.
|
void |
delete(java.lang.String path)
Deletes a directory and all its contents.
|
protected java.lang.String |
getPath(java.lang.String path)
Gets the absolute path corresponding to a path within the file system
|
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 |
pushd(java.lang.String path) |
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 FilePath m_root
public Chroot(FileSystem fs, java.lang.String root)
fs - The underlying file systemroot - The directory acting as the root of the current file systempublic java.util.List<java.lang.String> ls()
throws FileSystemException
FileSystemls in interface FileSystemls in class FilterFileSystemFileSystemException - 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 FileSystemls in class FilterFileSystempath - 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 FileSystemisDirectory in class FilterFileSystempath - The pathFileSystemException - Thrown if the operation could not be performed
for some reasonpublic boolean isFile(java.lang.String path)
throws FileSystemException
FileSystemisFile in interface FileSystemisFile in class FilterFileSystempath - 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 FileSystemwriteTo in class FilterFileSystemfilename - 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 FileSystemreadFrom in class FilterFileSystemfilename - 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 FileSystemchdir in class FilterFileSystempath - 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 FileSystempushd in class FilterFileSystempath - 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 mkdir(java.lang.String path)
throws FileSystemException
FileSystemmkdir in interface FileSystemmkdir in class FilterFileSystempath - 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 FileSystemrmdir in class FilterFileSystempath - 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 FileSystemdelete in class FilterFileSystempath - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonprotected java.lang.String getPath(java.lang.String path)
throws FileSystemException
path - The pathFileSystemException - Thrown if the current directory could not be
obtainedCopyright © Sylvain HallĂ©. All Rights Reserved.