Class TarFileSystem
java.lang.Object
org.apache.commons.vfs2.provider.AbstractVfsComponent
org.apache.commons.vfs2.provider.AbstractFileSystem
org.apache.commons.vfs2.provider.tar.TarFileSystem
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FileSystem
,VfsComponent
A read-only file system for Tar files.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<FileName,
FileObject> Cache doesn't need to be synchronized since it is read-only.private final char[]
private final File
private static final org.apache.commons.logging.Log
private org.apache.commons.compress.archivers.tar.TarArchiveInputStream
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
TarFileSystem
(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addCapabilities
(Collection<Capability> caps) Returns the capabilities of this file system.protected FileObject
createFile
(AbstractFileName name) Creates a file object.protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream
createTarFile
(File file) protected TarFileObject
createTarFileObject
(AbstractFileName name, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry) protected void
Closes the underlying link used to access the files.protected FileObject
getFileFromCache
(FileName name) Returns a cached file.getInputStream
(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry) protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream
void
init()
Initializes this component.protected void
putFileToCache
(FileObject file) Adds a file object to the cache.private void
will be called after all file-objects closed their streams.protected void
removeFileFromCache
(FileName name) remove a cached file.protected void
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileSystem
addJunction, addListener, close, closeCommunicationLink, decorateFileObject, doReplicateFile, fireFileChanged, fireFileCreated, fireFileDeleted, getAttribute, getFileSystemManager, getFileSystemOptions, getLastModTimeAccuracy, getParentLayer, getRoot, getRootName, getRootURI, hasCapability, isOpen, isReleaseable, notifyAllStreamsClosed, removeJunction, removeListener, replicateFile, resolveFile, resolveFile, setAttribute
Methods inherited from class org.apache.commons.vfs2.provider.AbstractVfsComponent
getContext, getLogger, setContext, setLogger
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
ENC
private final char[] ENC -
file
-
tarFile
private org.apache.commons.compress.archivers.tar.TarArchiveInputStream tarFile -
cache
Cache doesn't need to be synchronized since it is read-only.
-
-
Constructor Details
-
TarFileSystem
protected TarFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) throws FileSystemException - Throws:
FileSystemException
-
-
Method Details
-
addCapabilities
Returns the capabilities of this file system.- Specified by:
addCapabilities
in classAbstractFileSystem
- Parameters:
caps
- collections of Capabilities, can be immutable.
-
createFile
Creates a file object.- Specified by:
createFile
in classAbstractFileSystem
- Parameters:
name
- name referencing the new file.- Returns:
- new created FileObject.
- Throws:
FileSystemException
-
createTarFile
protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream createTarFile(File file) throws FileSystemException - Throws:
FileSystemException
-
createTarFileObject
protected TarFileObject createTarFileObject(AbstractFileName name, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry) -
doCloseCommunicationLink
protected void doCloseCommunicationLink()Description copied from class:AbstractFileSystem
Closes the underlying link used to access the files.- Overrides:
doCloseCommunicationLink
in classAbstractFileSystem
-
getFileFromCache
Returns a cached file.- Overrides:
getFileFromCache
in classAbstractFileSystem
- Parameters:
name
- name to search for.- Returns:
- file object or null if not found.
-
getInputStream
public InputStream getInputStream(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry) throws FileSystemException - Throws:
FileSystemException
-
getTarFile
protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream getTarFile() throws FileSystemException- Throws:
FileSystemException
-
init
Description copied from class:AbstractFileSystem
Initializes this component.- Specified by:
init
in interfaceVfsComponent
- Overrides:
init
in classAbstractFileSystem
- Throws:
FileSystemException
- if an error occurs.
-
putFileToCache
Adds a file object to the cache.- Overrides:
putFileToCache
in classAbstractFileSystem
- Parameters:
file
- the file to add.
-
recreateTarFile
will be called after all file-objects closed their streams. protected void notifyAllStreamsClosed() { closeCommunicationLink(); }- Throws:
FileSystemException
-
removeFileFromCache
remove a cached file.- Overrides:
removeFileFromCache
in classAbstractFileSystem
- Parameters:
name
- The file name to remove.
-
resetTarFile
- Throws:
FileSystemException
-