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:
java.io.Closeable
,java.lang.AutoCloseable
,FileSystem
,VfsComponent
public class TarFileSystem extends AbstractFileSystem
A read-only file system for Tar files.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<FileName,FileObject>
cache
Cache doesn't need to be synchronized since it is read-only.private char[]
ENC
private java.io.File
file
private static org.apache.commons.logging.Log
LOG
private org.apache.commons.compress.archivers.tar.TarArchiveInputStream
tarFile
-
Constructor Summary
Constructors Modifier Constructor Description protected
TarFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addCapabilities(java.util.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(java.io.File file)
protected TarFileObject
createTarFileObject(AbstractFileName name, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)
protected void
doCloseCommunicationLink()
Closes the underlying link used to access the files.protected FileObject
getFileFromCache(FileName name)
Returns a cached file.java.io.InputStream
getInputStream(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)
protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream
getTarFile()
void
init()
Initializes this component.protected void
putFileToCache(FileObject file)
Adds a file object to the cache.private void
recreateTarFile()
will be called after all file-objects closed their streams.protected void
removeFileFromCache(FileName name)
remove a cached file.protected void
resetTarFile()
-
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 Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
ENC
private final char[] ENC
-
file
private final java.io.File file
-
tarFile
private org.apache.commons.compress.archivers.tar.TarArchiveInputStream tarFile
-
cache
private final java.util.Map<FileName,FileObject> cache
Cache doesn't need to be synchronized since it is read-only.
-
-
Constructor Detail
-
TarFileSystem
protected TarFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) throws FileSystemException
- Throws:
FileSystemException
-
-
Method Detail
-
addCapabilities
protected void addCapabilities(java.util.Collection<Capability> caps)
Returns the capabilities of this file system.- Specified by:
addCapabilities
in classAbstractFileSystem
- Parameters:
caps
- collections of Capabilities, can be immutable.
-
createFile
protected FileObject createFile(AbstractFileName name) throws FileSystemException
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(java.io.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
protected FileObject getFileFromCache(FileName name)
Returns a cached file.- Overrides:
getFileFromCache
in classAbstractFileSystem
- Parameters:
name
- name to search for.- Returns:
- file object or null if not found.
-
getInputStream
public java.io.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
public void init() throws FileSystemException
Description copied from class:AbstractFileSystem
Initializes this component.- Specified by:
init
in interfaceVfsComponent
- Overrides:
init
in classAbstractFileSystem
- Throws:
FileSystemException
- if an error occurs.
-
putFileToCache
protected void putFileToCache(FileObject file)
Adds a file object to the cache.- Overrides:
putFileToCache
in classAbstractFileSystem
- Parameters:
file
- the file to add.
-
recreateTarFile
private void recreateTarFile() throws FileSystemException
will be called after all file-objects closed their streams. protected void notifyAllStreamsClosed() { closeCommunicationLink(); }- Throws:
FileSystemException
-
removeFileFromCache
protected void removeFileFromCache(FileName name)
remove a cached file.- Overrides:
removeFileFromCache
in classAbstractFileSystem
- Parameters:
name
- The file name to remove.
-
resetTarFile
protected void resetTarFile() throws FileSystemException
- Throws:
FileSystemException
-
-