| Modifier and Type | Field and Description |
|---|---|
| private boolean | atEof
True if stream is at EOF. |
| private final int | blockSize
The size of a block. |
| private TarArchiveEntry | currEntry
The meta-data about the current entry. |
| private int | currentSparseInputStreamIndex
The index of current input stream being read when reading sparse entries. |
| private long | entryOffset
How far into the entry the stream is at. |
| private long | entrySize
Size of the current . |
| private Map | globalPaxHeaders
The global PAX header. |
| private final List | globalSparseHeaders
The global sparse headers, this is only used in PAX Format 0.X. |
| private final boolean | |
| private final byte[] | recordBuffer
The buffer to store the TAR header. |
| private final int | recordSize
The size the TAR header. |
| private static final int | |
| private final byte[] | |
| private List | sparseInputStreams
Input streams for reading sparse entries. |
| private final ZipEncoding | zipEncoding
The encoding of the file. |
| Access | Constructor and Description |
|---|---|
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream)Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final boolean when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set to
lenient)TarArchiveEntry#UNKNOWN. When set to false such illegal fields cause an exception instead.Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final int the block size to use blockSize)Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final int the block size to use blockSize, final int the record size to use recordSize)Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final int the block size to use blockSize, final int the record size to use recordSize, final String name of the encoding to use for file names encoding)Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final int the block size to use blockSize, final int the record size to use recordSize, final String name of the encoding to use for file names encoding, final boolean when set to true illegal values for group/userid, mode, device numbers and timestamp will be ignored and the fields set to
lenient)TarArchiveEntry#UNKNOWN. When set to false such illegal fields cause an exception instead.Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final int the block size to use blockSize, final String name of the encoding to use for file names encoding)Constructs a new instance. |
| public | TarArchiveInputStream(final InputStream
the input stream to use inputStream, final String name of the encoding to use for file names encoding)Constructs a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| private void | applyPaxHeadersToCurrentEntry(final Map<String, String> headers, final List<TarArchiveStructSparse> sparseHeaders)
|
| public int | Returns: The number of available bytes for the current entry.Overrides java. |
| private void | buildSparseInputStreams()
Build the input streams consisting of all-zero input streams and non-zero input streams. |
| public boolean | canReadEntryData(final ArchiveEntry
the entry to test ae)Overrides org. |
| public void | close()
Overrides java. Implements java. |
| private void | consumeRemainderOfLastBlock()
This method is invoked once the end of the archive is hit, it tries to consume the remaining bytes under the assumption that the tool creating this archive has padded the last block. |
| private long | Returns: number of bytes actually skippedavailable bytes returned by inputStream.available() available, final long skipped bytes returned by inputStream.skip() skipped, final long bytes expected to skip expected)For FileInputStream, the skip always return the number you input, so we need the available bytes to determine how many bytes are actually skipped |
| public TarArchiveEntry | Returns: The current Archive EntryGets the current TAR Archive Entry that this input stream is processing |
| protected byte[] | Returns: The next entry in the archive as long name data, or null.Gets the next entry in this tar archive as long name data. |
| public TarArchiveEntry | Returns: the next entry, ornull if there are no more entriesImplements abstract org. |
| public TarArchiveEntry | Returns: The next TarEntry in the archive, or null.
Deprecated
Use
Gets the next entry in this tar archive.
getNextEntry().
|
| private byte[] | Returns: The next header in the archive, or null.Gets the next record in this tar archive. |
| public int | Returns: The TarBuffer record size.Gets the record size being used by this stream's buffer. |
| protected final boolean | |
| private boolean | |
| protected boolean | Returns: true if the record data is an End of ArchiveThe record data to check. record)Determine if an archive record indicate End of Archive. |
| public synchronized void | mark(final int
The limit to mark. markLimit)Overrides java. |
| public boolean | Returns: False.Overrides java. |
| public static boolean | Returns: true, if this stream is a tar archive stream, false otherwisethe bytes to check signature, final int the number of bytes to check length)Checks if the signature matches what is expected for a tar file. |
| private void | paxHeaders()
For PAX Format 0.0, the sparse headers(GNU.sparse.offset and GNU.sparse.numbytes) may appear multi times, and they look like: GNU.sparse.size=size GNU.sparse.numblocks=numblocks repeat numblocks times GNU.sparse.offset=offset GNU.sparse.numbytes=numbytes end repeat For PAX Format 0.1, the sparse headers are stored in a single variable : GNU.sparse.map GNU.sparse.map Map of non-null data chunks. |
| public int | Returns: The number of bytes read, or -1 at EOF.The buffer into which to place bytes read. buf, final int The offset at which to place bytes read. offset, int The number of bytes to read. numToRead)Overrides java. |
| private void | |
| private void | readOldGNUSparse()
Adds the sparse chunks from the current entry to the sparse chunks, including any additional sparse entries following the current entry. |
| protected byte[] | Returns: The record data or null if EOF has been hit.Read a record from the input stream and return the data. |
| private int | Returns: The number of bytes read, or -1 at EOF.The buffer into which to place bytes read. buf, final int The offset at which to place bytes read. offset, final int The number of bytes to read. numToRead)For sparse tar entries, there are many "holes"(consisting of all 0) in the file. |
| public synchronized void | reset()
Overrides java. |
| protected final void | |
| protected final void | |
| public long | Returns: the actual number of bytes skipped.the number of bytes to be skipped. n)Overrides java. n bytes of data from this input stream.
|
| private void | skipRecordPadding()
The last record block should be written at the full size, so skip any additional space used to fill a record after an entry. |
| private long | Returns: actual bytes of data skippedbytes of data to skip n)Skip n bytes from current input stream, if the current input stream doesn't have enough data to skip, jump to the next input stream and skip the rest bytes, keep doing this until total n bytes are skipped or the input streams are all skipped |
| private void | tryToConsumeSecondEOFRecord()
Tries to read the next record rewinding the stream if it is not an EOF record. |
| atEof | back to summary |
|---|---|
| private boolean atEof True if stream is at EOF. | |
| blockSize | back to summary |
|---|---|
| private final int blockSize The size of a block. | |
| currEntry | back to summary |
|---|---|
| private TarArchiveEntry currEntry The meta-data about the current entry. | |
| currentSparseInputStreamIndex | back to summary |
|---|---|
| private int currentSparseInputStreamIndex The index of current input stream being read when reading sparse entries. | |
| entryOffset | back to summary |
|---|---|
| private long entryOffset How far into the entry the stream is at. | |
| entrySize | back to summary |
|---|---|
| private long entrySize Size of the current . | |
| globalPaxHeaders | back to summary |
|---|---|
| private Map<String, String> globalPaxHeaders The global PAX header. | |
| globalSparseHeaders | back to summary |
|---|---|
| private final List<TarArchiveStructSparse> globalSparseHeaders The global sparse headers, this is only used in PAX Format 0.X. | |
| lenient | back to summary |
|---|---|
| private final boolean lenient | |
| recordBuffer | back to summary |
|---|---|
| private final byte[] recordBuffer The buffer to store the TAR header. | |
| recordSize | back to summary |
|---|---|
| private final int recordSize The size the TAR header. | |
| SMALL_BUFFER_SIZE | back to summary |
|---|---|
| private static final int SMALL_BUFFER_SIZE | |
| smallBuf | back to summary |
|---|---|
| private final byte[] smallBuf | |
| sparseInputStreams | back to summary |
|---|---|
| private List<InputStream> sparseInputStreams Input streams for reading sparse entries. | |
| zipEncoding | back to summary |
|---|---|
| private final ZipEncoding zipEncoding The encoding of the file. | |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final boolean lenient) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final int blockSize) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final int blockSize, final int recordSize) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final int blockSize, final int recordSize, final String encoding) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final int blockSize, final int recordSize, final String encoding, final boolean lenient) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final int blockSize, final String encoding) Constructs a new instance.
| |
| TarArchiveInputStream | back to summary |
|---|---|
| public TarArchiveInputStream(final InputStream inputStream, final String encoding) Constructs a new instance.
| |
| applyPaxHeadersToCurrentEntry | back to summary |
|---|---|
| private void applyPaxHeadersToCurrentEntry(final Map<String, String> headers, final List<TarArchiveStructSparse> sparseHeaders) throws IOException | |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Gets the available data that can be read from the current entry in the archive. This does not indicate how much data is left in the entire archive, only in the current entry. This value is determined from the entry's size header field and the amount of data already read from the current entry. Integer.MAX_VALUE is returned in case more than Integer.MAX_VALUE bytes are left in the current entry in the archive.
| |
| buildSparseInputStreams | back to summary |
|---|---|
| private void buildSparseInputStreams() throws IOException Build the input streams consisting of all-zero input streams and non-zero input streams. When reading from the non-zero input streams, the data is actually read from the original input stream. The size of each input stream is introduced by the sparse headers. NOTE : Some all-zero input streams and non-zero input streams have the size of 0. We DO NOT store the 0 size input streams because they are meaningless. | |
| canReadEntryData | back to summary |
|---|---|
| public boolean canReadEntryData(final ArchiveEntry ae) Overrides org. Whether this class is able to read the given entry.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Closes this stream. Calls the TarBuffer's close() method.
| |
| consumeRemainderOfLastBlock | back to summary |
|---|---|
| private void consumeRemainderOfLastBlock() throws IOException This method is invoked once the end of the archive is hit, it tries to consume the remaining bytes under the assumption that the tool creating this archive has padded the last block. | |
| getActuallySkipped | back to summary |
|---|---|
| private long getActuallySkipped(final long available, final long skipped, final long expected) throws IOException For FileInputStream, the skip always return the number you input, so we need the available bytes to determine how many bytes are actually skipped
| |
| getCurrentEntry | back to summary |
|---|---|
| public TarArchiveEntry getCurrentEntry() Gets the current TAR Archive Entry that this input stream is processing
| |
| getLongNameData | back to summary |
|---|---|
| protected byte[] getLongNameData() throws IOException Gets the next entry in this tar archive as long name data.
| |
| getNextEntry | back to summary |
|---|---|
| public TarArchiveEntry getNextEntry() throws IOException Implements abstract org. Returns the next Archive Entry in this Stream.
| |
| getNextTarEntry | back to summary |
|---|---|
| public TarArchiveEntry getNextTarEntry() throws IOException
Deprecated Use Gets the next entry in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry, and read the header and instantiate a new TarEntry from the header bytes and return that entry. If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached.
| |
| getRecord | back to summary |
|---|---|
| private byte[] getRecord() throws IOException Gets the next record in this tar archive. This will skip over any remaining data in the current entry, if there is one, and place the input stream at the header of the next entry.
If there are no more entries in the archive, null will be returned to indicate that the end of the archive has been reached. At the same time the
| |
| getRecordSize | back to summary |
|---|---|
| public int getRecordSize() Gets the record size being used by this stream's buffer.
| |
| isAtEOF | back to summary |
|---|---|
| protected final boolean isAtEOF() | |
| isDirectory | back to summary |
|---|---|
| private boolean isDirectory() | |
| isEOFRecord | back to summary |
|---|---|
| protected boolean isEOFRecord(final byte[] record) Determine if an archive record indicate End of Archive. End of archive is indicated by a record that consists entirely of null bytes.
| |
| mark | back to summary |
|---|---|
| public synchronized void mark(final int markLimit) Overrides java. Since we do not support marking just yet, we do nothing.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Since we do not support marking just yet, we return false.
| |
| matches | back to summary |
|---|---|
| public static boolean matches(final byte[] signature, final int length) Checks if the signature matches what is expected for a tar file.
| |
| paxHeaders | back to summary |
|---|---|
| private void paxHeaders() throws IOException For PAX Format 0.0, the sparse headers(GNU.sparse.offset and GNU.sparse.numbytes) may appear multi times, and they look like: GNU.sparse.size=size GNU.sparse.numblocks=numblocks repeat numblocks times GNU.sparse.offset=offset GNU.sparse.numbytes=numbytes end repeat For PAX Format 0.1, the sparse headers are stored in a single variable : GNU.sparse.map GNU.sparse.map Map of non-null data chunks. It is a string consisting of comma-separated values "offset,size[,offset-1,size-1...]" For PAX Format 1.X: The sparse map itself is stored in the file data block, preceding the actual file data. It consists of a series of decimal numbers delimited by newlines. The map is padded with nulls to the nearest block boundary. The first number gives the number of entries in the map. Following are map entries, each one consisting of two numbers giving the offset and size of the data block it describes. | |
| read | back to summary |
|---|---|
| public int read(final byte[] buf, final int offset, int numToRead) throws IOException Overrides java. Reads bytes from the current tar archive entry. This method is aware of the boundaries of the current entry in the archive and will deal with them as if they were this stream's start and EOF.
| |
| readGlobalPaxHeaders | back to summary |
|---|---|
| private void readGlobalPaxHeaders() throws IOException | |
| readOldGNUSparse | back to summary |
|---|---|
| private void readOldGNUSparse() throws IOException Adds the sparse chunks from the current entry to the sparse chunks, including any additional sparse entries following the current entry.
| |
| readRecord | back to summary |
|---|---|
| protected byte[] readRecord() throws IOException Read a record from the input stream and return the data.
| |
| readSparse | back to summary |
|---|---|
| private int readSparse(final byte[] buf, final int offset, final int numToRead) throws IOException For sparse tar entries, there are many "holes"(consisting of all 0) in the file. Only the non-zero data is stored in tar files, and they are stored separately. The structure of non-zero data is introduced by the sparse headers using the offset, where a block of non-zero data starts, and numbytes, the length of the non-zero data block. When reading sparse entries, the actual data is read out with "holes" and non-zero data combined together according to the sparse headers.
| |
| reset | back to summary |
|---|---|
| public synchronized void reset() Overrides java. Since we do not support marking just yet, we do nothing.
| |
| setAtEOF | back to summary |
|---|---|
| protected final void setAtEOF(final boolean b) | |
| setCurrentEntry | back to summary |
|---|---|
| protected final void setCurrentEntry(final TarArchiveEntry e) | |
| skip | back to summary |
|---|---|
| public long skip(final long n) throws IOException Overrides java. Skips over and discards
| |
| skipRecordPadding | back to summary |
|---|---|
| private void skipRecordPadding() throws IOException The last record block should be written at the full size, so skip any additional space used to fill a record after an entry.
| |
| skipSparse | back to summary |
|---|---|
| private long skipSparse(final long n) throws IOException Skip n bytes from current input stream, if the current input stream doesn't have enough data to skip, jump to the next input stream and skip the rest bytes, keep doing this until total n bytes are skipped or the input streams are all skipped
| |
| tryToConsumeSecondEOFRecord | back to summary |
|---|---|
| private void tryToConsumeSecondEOFRecord() throws IOException Tries to read the next record rewinding the stream if it is not an EOF record. This is meant to protect against cases where a tar implementation has written only one EOF record when two are expected. Actually this won't help since a non-conforming implementation likely won't fill full blocks consisting of - by default - ten records either so we probably have already read beyond the archive anyway. | |