Class JavaZipFileSystem
java.lang.Object
org.jboss.vfs.spi.JavaZipFileSystem
- All Implemented Interfaces:
Closeable, AutoCloseable, FileSystem
This implementation is backed by a zip file. The provided file must be owned by this instance; otherwise, if the
file disappears unexpectedly, the filesystem will malfunction.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Fileprivate final Fileprivate final JavaZipFileSystem.ZipNodeprivate final TempDirprivate final JarFileprivate final long -
Constructor Summary
ConstructorsConstructorDescriptionJavaZipFileSystem(File archiveFile, TempDir tempDir) Create a new instance.JavaZipFileSystem(String name, InputStream inputStream, TempDir tempDir) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate Filevoidclose()Destroy this filesystem instance.booleandelete(VirtualFile mountPoint, VirtualFile target) Attempt to delete a virtual file within this filesystem.booleanexists(VirtualFile mountPoint, VirtualFile target) Ascertain the existance of a virtual file within this filesystem.getCodeSigners(VirtualFile mountPoint, VirtualFile target) Get theCodeSigners for a the virtual file.getDirectoryEntries(VirtualFile mountPoint, VirtualFile target) Read a directory.private JavaZipFileSystem.ZipNodegetExistingZipNode(VirtualFile mountPoint, VirtualFile target) getFile(VirtualFile mountPoint, VirtualFile target) Get a realFilefor the given path within this filesystem.longgetLastModified(VirtualFile mountPoint, VirtualFile target) Get the last modification time of a virtual file within this filesystem.Get theFilesource provided at mount time.Get the root URI for this file system, ornullif there is no valid root URI.longgetSize(VirtualFile mountPoint, VirtualFile target) Get the size of a virtual file within this filesystem.private JavaZipFileSystem.ZipNodegetZipNode(VirtualFile mountPoint, VirtualFile target) booleanisDirectory(VirtualFile mountPoint, VirtualFile target) Ascertain whether a virtual file within this filesystem is a directory.booleanisFile(VirtualFile mountPoint, VirtualFile target) Ascertain whether a virtual file within this filesystem is a plain file.booleanDetermine whether this filesystem is read-only.private static <T> Iterable<T> iter(Enumeration<T> entries) openInputStream(VirtualFile mountPoint, VirtualFile target) Open an input stream for the file at the given relative path.
-
Field Details
-
zipFile
-
archiveFile
-
zipTime
private final long zipTime -
rootNode
-
tempDir
-
contentsDir
-
-
Constructor Details
-
JavaZipFileSystem
Create a new instance.- Parameters:
name- the name of the source archiveinputStream- an input stream from the source archivetempDir- the temp dir into which zip information is stored- Throws:
IOException- if an I/O error occurs
-
JavaZipFileSystem
Create a new instance.- Parameters:
archiveFile- the original archive filetempDir- the temp dir into which zip information is stored- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
iter
-
getFile
Get a realFilefor 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 returnedFilemay 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.- Specified by:
getFilein interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
- the file instance
- Throws:
IOException- if an I/O error occurs
-
openInputStream
Open an input stream for the file at the given relative path.- Specified by:
openInputStreamin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
- the input stream
- Throws:
IOException- if an I/O error occurs
-
delete
Attempt to delete a virtual file within this filesystem.- Specified by:
deletein interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
trueif the file was deleted,falseif it failed for any reason
-
getSize
Get the size of a virtual file within this filesystem.- Specified by:
getSizein interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
- the size, in bytes, or 0L if the file does not exist or is a directory
-
getLastModified
Get the last modification time of a virtual file within this filesystem.- Specified by:
getLastModifiedin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
- the modification time in milliseconds, or 0L if the file does not exist or if an error occurs
-
exists
Ascertain the existance of a virtual file within this filesystem.- Specified by:
existsin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
trueif the file exists,falseotherwise
-
isFile
Ascertain whether a virtual file within this filesystem is a plain file.- Specified by:
isFilein interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
trueif the file exists and is a plain file,falseotherwise
-
isDirectory
Ascertain whether a virtual file within this filesystem is a directory.- Specified by:
isDirectoryin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
trueif the file exists and is a directory,falseotherwise
-
getDirectoryEntries
Read a directory. Returns all the simple path names (excluding "." and ".."). The returned list will be empty if the node is not a directory.- Specified by:
getDirectoryEntriesin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
- the collection of children names
-
getCodeSigners
Get theCodeSigners for a the virtual file.- Specified by:
getCodeSignersin interfaceFileSystem- Parameters:
mountPoint- the mount point of the filesystem instance (guaranteed to be a parent oftarget)target- the virtual file to act upon- Returns:
CodeSignerfor the virtual file or null if not signed.
-
getZipNode
-
getExistingZipNode
private JavaZipFileSystem.ZipNode getExistingZipNode(VirtualFile mountPoint, VirtualFile target) throws FileNotFoundException - Throws:
FileNotFoundException
-
isReadOnly
public boolean isReadOnly()Determine whether this filesystem is read-only. A read-only filesystem prohibits file modification or deletion. It is not an error to mount a read-write filesystem within a read-only filesystem however (this operation does not take place within theFileSystemimplementation).- Specified by:
isReadOnlyin interfaceFileSystem- Returns:
trueif the filesystem is read-only
-
getMountSource
Get theFilesource provided at mount time.- Specified by:
getMountSourcein interfaceFileSystem- Returns:
- the source used for mounting
-
getRootURI
Description copied from interface:FileSystemGet the root URI for this file system, ornullif there is no valid root URI.- Specified by:
getRootURIin interfaceFileSystem- Returns:
- the root URI
- Throws:
URISyntaxException- if the URI isn't valid
-
close
Destroy this filesystem instance. After this method is called, the filesystem may not be used in any way. This method should be called only after all mounts of this filesystem have been cleared; otherwise, VFS accesses may result inIOExceptions.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFileSystem- Throws:
IOException- if an I/O error occurs during close
-
buildFile
-