@NotThreadSafe public class TarInputShop extends Object implements InputShop<TarDriverEntry>
TarArchiveInputStream as a randomly accessible archive.
Warning: The constructor of this class extracts each entry in the archive to a temporary file. This may be very time and space consuming for large archives, but is the fastest implementation for subsequent random access, since there is no way the archive driver could predict the client application's behaviour.
TarOutputShop| Modifier and Type | Field and Description |
|---|---|
private static int |
CHECKSUM_OFFSET |
static int |
DEFAULT_BLKSIZE
Default block size
|
private static int |
DEFAULT_RCDSIZE
Default record size
|
private Map<String,TarDriverEntry> |
entries
Maps entry names to I/O pool entries.
|
private static byte[] |
NULL_RECORD |
| Constructor and Description |
|---|
TarInputShop(TarDriver driver,
InputStream in)
Extracts the entire TAR input stream into a temporary directory in order
to allow subsequent random access to its entries.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
private void |
close0() |
TarDriverEntry |
getEntry(String name) |
InputSocket<TarDriverEntry> |
getInputSocket(String name) |
private static String |
getName(ArchiveEntry entry)
Returns the fixed name of the given TAR entry, ensuring that it ends
with a
EntryName.SEPARATOR if it's a directory. |
int |
getSize() |
Iterator<TarDriverEntry> |
iterator() |
private static TarArchiveInputStream |
newValidatedTarInputStream(InputStream in)
Returns a newly created and validated
TarArchiveInputStream. |
(package private) static InputStream |
readAhead(InputStream in,
byte[] buf)
Fills
buf with data from the given input stream and
returns an input stream from which you can still read all data,
including the data in buf. |
private static void |
readFully(InputStream in,
byte[] buf) |
private static final int CHECKSUM_OFFSET
public static final int DEFAULT_BLKSIZE
private static final int DEFAULT_RCDSIZE
private final Map<String,TarDriverEntry> entries
private static final byte[] NULL_RECORD
@CreatesObligation public TarInputShop(TarDriver driver, @WillNotClose InputStream in) throws IOException
in - The input stream from which this input archive file should be
initialized. This stream is not used by any of the methods in
this class after the constructor has terminated and is
never closed!
So it is safe and recommended to close it upon termination
of this constructor.IOExceptionpublic void close()
throws IOException
close in interface InputShop<TarDriverEntry>close in interface Closeableclose in interface AutoCloseableIOExceptionprivate void close0()
throws IOException
IOException@CheckForNull public final TarDriverEntry getEntry(String name)
getEntry in interface EntryContainer<TarDriverEntry>public InputSocket<TarDriverEntry> getInputSocket(String name)
getInputSocket in interface InputService<TarDriverEntry>private static String getName(ArchiveEntry entry)
EntryName.SEPARATOR if it's a directory.entry - the TAR entry.public final int getSize()
getSize in interface EntryContainer<TarDriverEntry>public final Iterator<TarDriverEntry> iterator()
iterator in interface EntryContainer<TarDriverEntry>iterator in interface InputService<TarDriverEntry>iterator in interface Iterable<TarDriverEntry>private static TarArchiveInputStream newValidatedTarInputStream(InputStream in) throws IOException
TarArchiveInputStream.
This method performs a simple validation by computing the checksum
for the first record only.
This method is required because the TarArchiveInputStream
unfortunately does not do any validation!IOExceptionstatic InputStream readAhead(InputStream in, byte[] buf) throws IOException
buf with data from the given input stream and
returns an input stream from which you can still read all data,
including the data in buf.in - The stream to read from. May not be null.buf - The buffer to fill entirely with data.in did.IOException - If buf couldn't get filled entirely.private static void readFully(InputStream in, byte[] buf) throws IOException
IOExceptionCopyright © 2005-2012 Schlichtherle IT Services. All Rights Reserved.