| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final SeekableByteChannel | |
| private final int | |
| private TarArchiveEntry | currEntry
The meta-data about the current entry |
| private final LinkedList | |
| private Map | |
| private final List | |
| private boolean | |
| private final boolean | |
| private final ByteBuffer | |
| private final int | |
| private static final int | |
| private final byte[] | |
| private final Map | |
| private final ZipEncoding | zipEncoding
The encoding of the tar file |
| Access | Constructor and Description |
|---|---|
| public | |
| public | TarFile(final byte[]
the content to use content, 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.Constructor for TarFile. |
| public | |
| public | |
| public | TarFile(final File
the file of the archive to use archive, 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.Constructor for TarFile. |
| public | |
| public | |
| public | TarFile(final Path
the path of the archive to use archivePath, 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.Constructor for TarFile. |
| public | |
| public | |
| public | TarFile(final SeekableByteChannel
the seekable byte channel to use archive, final int the blocks size to use blockSize, final int the record size to use recordSize, final String the encoding to use 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.Constructor for TarFile. |
| Modifier and Type | Method and Description |
|---|---|
| private void | applyPaxHeadersToCurrentEntry(final Map<String, String>
Headers read from the pax header headers, final List<TarArchiveStructSparse> Sparse headers read from pax header sparseHeaders)Update the current entry with the read pax headers |
| private void | buildSparseInputStreams()
Build the input streams consisting of all-zero input streams and non-zero input streams. |
| public void | close()
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. |
| public List | |
| public InputStream | Returns: Input stream of the provided entryEntry to get the input stream from entry)Gets the input stream for the provided Tar Archive Entry. |
| private 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. |
| private TarArchiveEntry | Returns: The next TarEntry in the archive, or null if there is no next entry.Gets the next entry in this tar archive. |
| private ByteBuffer | Returns: The next TarEntry in the archive, or null if there is no next entry.Gets the next record in this tar archive. |
| protected final boolean | |
| private boolean | |
| private boolean | |
| 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 |
| 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. |
| private ByteBuffer | Returns: The record data or null if EOF has been hit.Read a record from the input stream and return the data. |
| private void | |
| private void | |
| protected final void | |
| 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 void | throwExceptionIfPositionIsNotInArchive()
Checks if the current position of the SeekableByteChannel is in the archive. |
| private void | tryToConsumeSecondEOFRecord()
Tries to read the next record resetting the position in the archive if it is not an EOF record. |
| archive | back to summary |
|---|---|
| private final SeekableByteChannel archive | |
| blockSize | back to summary |
|---|---|
| private final int blockSize | |
| currEntry | back to summary |
|---|---|
| private TarArchiveEntry currEntry The meta-data about the current entry | |
| entries | back to summary |
|---|---|
| private final LinkedList<TarArchiveEntry> entries | |
| globalPaxHeaders | back to summary |
|---|---|
| private Map<String, String> globalPaxHeaders | |
| globalSparseHeaders | back to summary |
|---|---|
| private final List<TarArchiveStructSparse> globalSparseHeaders | |
| hasHitEOF | back to summary |
|---|---|
| private boolean hasHitEOF | |
| lenient | back to summary |
|---|---|
| private final boolean lenient | |
| recordBuffer | back to summary |
|---|---|
| private final ByteBuffer recordBuffer | |
| recordSize | back to summary |
|---|---|
| private final int recordSize | |
| 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 final Map<String, List<InputStream>> sparseInputStreams | |
| zipEncoding | back to summary |
|---|---|
| private final ZipEncoding zipEncoding The encoding of the tar file | |
| TarFile | back to summary |
|---|---|
| public TarFile(final byte[] content) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final byte[] content, final boolean lenient) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final byte[] content, final String encoding) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final File archive) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final File archive, final boolean lenient) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final File archive, final String encoding) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final Path archivePath) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final Path archivePath, final boolean lenient) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final Path archivePath, final String encoding) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final SeekableByteChannel content) throws IOException Constructor for TarFile.
| |
| TarFile | back to summary |
|---|---|
| public TarFile(final SeekableByteChannel archive, final int blockSize, final int recordSize, final String encoding, final boolean lenient) throws IOException Constructor for TarFile.
| |
| applyPaxHeadersToCurrentEntry | back to summary |
|---|---|
| private void applyPaxHeadersToCurrentEntry(final Map<String, String> headers, final List<TarArchiveStructSparse> sparseHeaders) throws IOException Update the current entry with the read pax headers
| |
| 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. Implementation 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. | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| 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. | |
| getEntries | back to summary |
|---|---|
| public List Gets all TAR Archive Entries from the TarFile
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream(final TarArchiveEntry entry) throws IOException Gets the input stream for the provided Tar Archive Entry.
| |
| getLongNameData | back to summary |
|---|---|
| private byte[] getLongNameData() throws IOException Gets the next entry in this tar archive as long name data.
| |
| getNextTarEntry | back to summary |
|---|---|
| private TarArchiveEntry getNextTarEntry() throws IOException Gets the next entry in this tar archive. This will skip to the end of the current entry, if there is one, and place the position of the channel 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 ByteBuffer 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
| |
| isAtEOF | back to summary |
|---|---|
| protected final boolean isAtEOF() | |
| isDirectory | back to summary |
|---|---|
| private boolean isDirectory() | |
| isEOFRecord | back to summary |
|---|---|
| private boolean isEOFRecord(final ByteBuffer headerBuf) | |
| 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: | |
| 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 |
|---|---|
| private ByteBuffer readRecord() throws IOException Read a record from the input stream and return the data.
| |
| repositionForwardBy | back to summary |
|---|---|
| private void repositionForwardBy(final long offset) throws IOException | |
| repositionForwardTo | back to summary |
|---|---|
| private void repositionForwardTo(final long newPosition) throws IOException | |
| setAtEOF | back to summary |
|---|---|
| protected final void setAtEOF(final boolean b) | |
| 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
| |
| throwExceptionIfPositionIsNotInArchive | back to summary |
|---|---|
| private void throwExceptionIfPositionIsNotInArchive() throws IOException Checks if the current position of the SeekableByteChannel is in the archive.
| |
| tryToConsumeSecondEOFRecord | back to summary |
|---|---|
| private void tryToConsumeSecondEOFRecord() throws IOException Tries to read the next record resetting the position in the archive 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.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final SeekableByteChannel | |
| private int | |
| private final TarArchiveEntry | |
| private long |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected int | read(final long
position to start the read. pos, final ByteBuffer buffer to add the read content. buf)Implements abstract org. ByteBuffer.
|
| private int | |
| private int |
| channel | back to summary |
|---|---|
| private final SeekableByteChannel channel | |
| currentSparseInputStreamIndex | back to summary |
|---|---|
| private int currentSparseInputStreamIndex | |
| entry | back to summary |
|---|---|
| private final TarArchiveEntry entry | |
| entryOffset | back to summary |
|---|---|
| private long entryOffset | |
| BoundedTarEntryInputStream | back to summary |
|---|---|
| pack-priv BoundedTarEntryInputStream(final TarArchiveEntry entry, final SeekableByteChannel channel) throws IOException | |
| read | back to summary |
|---|---|
| protected int read(final long pos, final ByteBuffer buf) throws IOException Implements abstract org. Doc from org. Reads content of the stream into a
| |
| readArchive | back to summary |
|---|---|
| private int readArchive(final long pos, final ByteBuffer buf) throws IOException | |
| readSparse | back to summary |
|---|---|
| private int readSparse(final long pos, final ByteBuffer buf, final int numToRead) throws IOException | |