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.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTarFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCapabilities(java.util.Collection<Capability> caps)Returns the capabilities of this file system.protected FileObjectcreateFile(AbstractFileName name)Creates a file object.protected org.apache.commons.compress.archivers.tar.TarArchiveInputStreamcreateTarFile(java.io.File file)Creates a new TarArchiveInputStream.protected TarFileObjectcreateTarFileObject(AbstractFileName fileName, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)Creates a new TarFileObject.protected voiddoCloseCommunicationLink()Closes the underlying link used to access the files.protected FileObjectgetFileFromCache(FileName name)Returns a cached file.java.io.InputStreamgetInputStream(org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)Returns the input stream for the given entry.protected org.apache.commons.compress.archivers.tar.TarArchiveInputStreamgetTarFile()Gets the TarArchiveInputStream.voidinit()Initializes this component.protected voidputFileToCache(FileObject file)Adds a file object to the cache.protected voidremoveFileFromCache(FileName name)remove a cached file.protected voidresetTarFile()Resets the tar file.-
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
-
-
-
-
Constructor Detail
-
TarFileSystem
protected TarFileSystem(AbstractFileName rootName, FileObject parentLayer, FileSystemOptions fileSystemOptions) throws FileSystemException
Constructs a new instance.- Parameters:
rootName- The root file name of this file system.parentLayer- The parent layer of this file system.fileSystemOptions- Options to build this file system.- Throws:
FileSystemException- if a file system error occurs.
-
-
Method Detail
-
addCapabilities
protected void addCapabilities(java.util.Collection<Capability> caps)
Returns the capabilities of this file system.- Specified by:
addCapabilitiesin classAbstractFileSystem- Parameters:
caps- collections of Capabilities, can be immutable.
-
createFile
protected FileObject createFile(AbstractFileName name) throws FileSystemException
Creates a file object.- Specified by:
createFilein 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
Creates a new TarArchiveInputStream.- Parameters:
file- the file.- Returns:
- a new TarArchiveInputStream.
- Throws:
FileSystemException- if a file system error occurs.
-
createTarFileObject
protected TarFileObject createTarFileObject(AbstractFileName fileName, org.apache.commons.compress.archivers.tar.TarArchiveEntry entry)
Creates a new TarFileObject.- Parameters:
fileName- the file name.entry- the archive entry.- Returns:
- a new TarFileObject.
-
doCloseCommunicationLink
protected void doCloseCommunicationLink()
Description copied from class:AbstractFileSystemCloses the underlying link used to access the files.- Overrides:
doCloseCommunicationLinkin classAbstractFileSystem
-
getFileFromCache
protected FileObject getFileFromCache(FileName name)
Returns a cached file.- Overrides:
getFileFromCachein 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
Returns the input stream for the given entry.- Parameters:
entry- The entry to seek.- Returns:
- the input stream for the given entry.
- Throws:
FileSystemException- If an I/O error occurs.
-
getTarFile
protected org.apache.commons.compress.archivers.tar.TarArchiveInputStream getTarFile() throws FileSystemException
Gets the TarArchiveInputStream.- Returns:
- the TarArchiveInputStream.
- Throws:
FileSystemException- if a file system error occurs.
-
init
public void init() throws FileSystemException
Description copied from class:AbstractFileSystemInitializes this component.- Specified by:
initin interfaceVfsComponent- Overrides:
initin classAbstractFileSystem- Throws:
FileSystemException- if an error occurs.
-
putFileToCache
protected void putFileToCache(FileObject file)
Adds a file object to the cache.- Overrides:
putFileToCachein classAbstractFileSystem- Parameters:
file- the file to add.
-
removeFileFromCache
protected void removeFileFromCache(FileName name)
remove a cached file.- Overrides:
removeFileFromCachein classAbstractFileSystem- Parameters:
name- The file name to remove.
-
resetTarFile
protected void resetTarFile() throws FileSystemException
Resets the tar file.- Throws:
FileSystemException- if a file system error occurs.
-
-