public class ReadZipFile extends RamDisk
RamDisk; however, it does
not extract the archive into memory: it only uses its parent's
tree structure to store the listing of folders without having to re-scan
the file entries in the zip archive every time an operation such as
RamDisk.ls() is invoked. Only when readFrom(String) is called
does the file system move the location of the pointer within the zip
file stream to the appropriate location; the corresponding file is then
extracted on the fly. This way, it is possible to interact with a large
archive, without the need to completely uncompress it before use.RamDisk.RamdiskFileNode, RamDisk.RamdiskFileOutputStream, RamDisk.RamdiskFolderNode, RamDisk.RamdiskNodeFileSystem.OpenState| Modifier and Type | Field and Description |
|---|---|
protected java.io.InputStream |
m_input
The input stream from which the contents of the zip file is to be read.
|
protected java.util.zip.ZipInputStream |
m_zipInput
A stream to read from a zip file.
|
m_currentDir, m_dirStack, m_root, m_state| Constructor and Description |
|---|
ReadZipFile(java.io.InputStream input)
Creates a new zip file system in read mode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Stops the interaction with the file system.
|
void |
delete(java.lang.String path)
Deletes a directory and all its contents.
|
protected java.util.zip.ZipEntry |
getZipEntry(java.lang.String path)
Gets the zip entry corresponding to a given path.
|
void |
mkdir(java.lang.String path)
Creates a directory if it does not exist.
|
void |
open()
Starts the interaction with 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.
|
chdir, createFileNode, createFolderNode, getSize, isDirectory, isFile, locate, locate, ls, ls, ls, popd, pushd, pwdprotected java.util.zip.ZipInputStream m_zipInput
protected java.io.InputStream m_input
public ReadZipFile(java.io.InputStream input)
input - The input stream from which the contents of the zip file is
to be readpublic void open()
throws FileSystemException
FileSystemFileSystemException if called before
this method.open in interface FileSystemopen in class RamDiskFileSystemException - Thrown if the interaction with the file system
cannot be startedpublic 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 RamDiskfilename - 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 RamDiskfilename - The name of the file to which data is to be writtenFileSystemException - 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 RamDiskpath - 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 RamDiskpath - 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 RamDiskpath - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonpublic void close()
throws FileSystemException
FileSystemFileSystemException if called after
this method.close in interface FileSystemclose in class RamDiskFileSystemException - Thrown if an error occurred while stopping the
interaction with the file systemprotected java.util.zip.ZipEntry getZipEntry(java.lang.String path)
throws java.io.IOException
path - The path to get the entry forjava.io.IOException - Thrown if resetting the input stream failsCopyright © Sylvain HallĂ©. All Rights Reserved.