public final class JavaZipFileSystem extends java.lang.Object implements FileSystem
| Modifier and Type | Class and Description |
|---|---|
private static class |
JavaZipFileSystem.ZipNode |
| Modifier and Type | Field and Description |
|---|---|
private java.io.File |
archiveFile |
private java.io.File |
contentsDir |
private JavaZipFileSystem.ZipNode |
rootNode |
private TempDir |
tempDir |
private java.util.jar.JarFile |
zipFile |
private long |
zipTime |
| Constructor and Description |
|---|
JavaZipFileSystem(java.io.File archiveFile,
TempDir tempDir)
Create a new instance.
|
JavaZipFileSystem(java.lang.String name,
java.io.InputStream inputStream,
TempDir tempDir)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
private java.io.File |
buildFile(java.io.File contentsDir,
java.lang.String name) |
void |
close()
Destroy this filesystem instance.
|
boolean |
delete(VirtualFile mountPoint,
VirtualFile target)
Attempt to delete a virtual file within this filesystem.
|
boolean |
exists(VirtualFile mountPoint,
VirtualFile target)
Ascertain the existance of a virtual file within this filesystem.
|
java.security.CodeSigner[] |
getCodeSigners(VirtualFile mountPoint,
VirtualFile target)
Get the
CodeSigners for a the virtual file. |
java.util.List<java.lang.String> |
getDirectoryEntries(VirtualFile mountPoint,
VirtualFile target)
Read a directory.
|
private JavaZipFileSystem.ZipNode |
getExistingZipNode(VirtualFile mountPoint,
VirtualFile target) |
java.io.File |
getFile(VirtualFile mountPoint,
VirtualFile target)
Get a real
File for the given path within this filesystem. |
long |
getLastModified(VirtualFile mountPoint,
VirtualFile target)
Get the last modification time of a virtual file within this filesystem.
|
java.io.File |
getMountSource()
Get the
File source provided at mount time. |
java.net.URI |
getRootURI()
Get the root URI for this file system, or
null if there is no valid root URI. |
long |
getSize(VirtualFile mountPoint,
VirtualFile target)
Get the size of a virtual file within this filesystem.
|
private JavaZipFileSystem.ZipNode |
getZipNode(VirtualFile mountPoint,
VirtualFile target) |
boolean |
isDirectory(VirtualFile mountPoint,
VirtualFile target)
Ascertain whether a virtual file within this filesystem is a directory.
|
boolean |
isFile(VirtualFile mountPoint,
VirtualFile target)
Ascertain whether a virtual file within this filesystem is a plain file.
|
boolean |
isReadOnly()
Determine whether this filesystem is read-only.
|
private static <T> java.lang.Iterable<T> |
iter(java.util.Enumeration<T> entries) |
java.io.InputStream |
openInputStream(VirtualFile mountPoint,
VirtualFile target)
Open an input stream for the file at the given relative path.
|
private final java.util.jar.JarFile zipFile
private final java.io.File archiveFile
private final long zipTime
private final JavaZipFileSystem.ZipNode rootNode
private final TempDir tempDir
private final java.io.File contentsDir
public JavaZipFileSystem(java.lang.String name,
java.io.InputStream inputStream,
TempDir tempDir)
throws java.io.IOException
name - the name of the source archiveinputStream - an input stream from the source archivetempDir - the temp dir into which zip information is storedjava.io.IOException - if an I/O error occurspublic JavaZipFileSystem(java.io.File archiveFile,
TempDir tempDir)
throws java.io.IOException
archiveFile - the original archive filetempDir - the temp dir into which zip information is storedjava.io.IOException - if an I/O error occursprivate static <T> java.lang.Iterable<T> iter(java.util.Enumeration<T> entries)
public java.io.File getFile(VirtualFile mountPoint, VirtualFile target) throws java.io.IOException
File for the given path within this filesystem. Some filesystem types will need to make a copy
in order to return this file; such copies should be cached and retained until the filesystem is closed. Depending
on the file type, the real path of the returned File may or may not bear a relationship to the virtual
path provided; if such a relationship is required, it must be negotiated at the time the filesystem is mounted.getFile in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponjava.io.IOException - if an I/O error occurspublic java.io.InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws java.io.IOException
openInputStream in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponjava.io.IOException - if an I/O error occurspublic boolean delete(VirtualFile mountPoint, VirtualFile target)
delete in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act upontrue if the file was deleted, false if it failed for any reasonpublic long getSize(VirtualFile mountPoint, VirtualFile target)
getSize in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponpublic long getLastModified(VirtualFile mountPoint, VirtualFile target)
getLastModified in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponpublic boolean exists(VirtualFile mountPoint, VirtualFile target)
exists in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act upontrue if the file exists, false otherwisepublic boolean isFile(VirtualFile mountPoint, VirtualFile target)
isFile in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act upontrue if the file exists and is a plain file, false otherwisepublic boolean isDirectory(VirtualFile mountPoint, VirtualFile target)
isDirectory in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act upontrue if the file exists and is a directory, false otherwisepublic java.util.List<java.lang.String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target)
getDirectoryEntries in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponpublic java.security.CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target)
CodeSigners for a the virtual file.getCodeSigners in interface FileSystemmountPoint - the mount point of the filesystem instance (guaranteed to be a parent of target)target - the virtual file to act uponCodeSigner for the virtual file or null if not signed.private JavaZipFileSystem.ZipNode getZipNode(VirtualFile mountPoint, VirtualFile target)
private JavaZipFileSystem.ZipNode getExistingZipNode(VirtualFile mountPoint, VirtualFile target) throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionpublic boolean isReadOnly()
FileSystem implementation).isReadOnly in interface FileSystemtrue if the filesystem is read-onlypublic java.io.File getMountSource()
File source provided at mount time.getMountSource in interface FileSystempublic java.net.URI getRootURI()
throws java.net.URISyntaxException
FileSystemnull if there is no valid root URI.getRootURI in interface FileSystemjava.net.URISyntaxException - if the URI isn't validpublic void close()
throws java.io.IOException
IOExceptions.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface FileSystemjava.io.IOException - if an I/O error occurs during closeprivate java.io.File buildFile(java.io.File contentsDir,
java.lang.String name)