| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| pack-priv static final ZipEncoding | |
| pack-priv static final ZipEncoding | FALLBACK_ENCODING
Encapsulates the algorithms used up to Commons Compress 1.3 as ZipEncoding. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static long | Returns: The computed checksum.The tar entry's header buffer. buf)Computes the checksum of a tar entry header. |
| private static String | exceptionMessage(final byte[] buffer, final int offset, final int length, final int current, final byte currentByte)
|
| private static void | formatBigIntegerBinary(final long value, final byte[] buf, final int offset, final int length, final boolean negative)
|
| public static int | Returns: The updated value of offset, i.e. offset+lengthThe value to convert value, final byte[] The destination buffer buf, final int The starting offset into the buffer. offset, final int The size of the buffer. length)Writes an octal value into a buffer. |
| private static void | formatLongBinary(final long value, final byte[] buf, final int offset, final int length, final boolean negative)
|
| public static int | Returns: The updated offsetThe value to write as octal value, final byte[] The destinationbuffer. buf, final int The starting offset into the buffer. offset, final int The length of the buffer length)Writes an octal long integer into a buffer. |
| public static int | Returns: The updated offset.The value to write into the buffer. value, final byte[] The destination buffer. buf, final int The starting offset into the buffer. offset, final int The length of the buffer. length)Writes a long integer into a buffer as an octal string if this will fit, or as a binary number otherwise. |
| public static int | Returns: The updated offset, i.e. offset + lengthThe header name from which to copy the characters. name, final byte[] The buffer where the name is to be stored. buf, final int The starting offset into the buffer offset, final int The maximum number of header bytes to copy. length)Copies a name into a buffer. |
| public static int | Returns: The updated offset, i.e. offset + lengthThe header name from which to copy the characters. name, final byte[] The buffer where the name is to be stored. buf, final int The starting offset into the buffer offset, final int The maximum number of header bytes to copy. length, final ZipEncoding name of the encoding to use for file names encoding)Copies a name into a buffer. |
| public static int | Returns: The updated offset, i.e. offset+lengthThe value to write value, final byte[] The buffer to receive the output buf, final int The starting offset into the buffer offset, final int The size of the output buffer length)Writes an octal integer into a buffer. |
| public static void | formatUnsignedOctalString(final long
number to convert to octal - treated as unsigned value, final byte[] destination buffer buffer, final int starting offset in buffer offset, final int length of buffer to fill length)Fills a buffer with unsigned octal number, padded with leading zeroes. |
| private static long | parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative)
|
| private static long | |
| public static boolean | Returns: The boolean value of the bytes.The buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset)Parses a boolean byte from a buffer. |
| protected static List | Returns: unmodifiable list of sparse headers parsed from sparse mapthe sparse map string consisting of comma-separated values "offset,size[,offset-1,size-1...]" sparseMap)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 static String | Returns: The entry name.The buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset, final int The maximum number of bytes to parse. length)Parses an entry name from a buffer. |
| public static String | Returns: The entry name.The buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset, final int The maximum number of bytes to parse. length, final ZipEncoding name of the encoding to use for file names encoding)Parses an entry name from a buffer. |
| public static long | Returns: The long value of the octal string.The buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset, final int The maximum number of bytes to parse - must be at least 2 bytes. length)Parses an octal string from a buffer. |
| public static long | Returns: The long value of the octal or binary string.The buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset, final int The maximum number of bytes to parse. length)Computes the value contained in a byte buffer. |
| protected static List | Returns: sparse headers parsed from sparse mapthe sparse map string consisting of comma-separated values "offset,size[,offset-1,size-1...]" sparseMap)
Deprecated
use #parseFromPAX01SparseHeaders instead
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. |
| protected static List | Returns: sparse headersparsing source. inputStream, final int The size the TAR header recordSize)For PAX Format 1.X: The sparse map itself is stored in the file data block, preceding the actual file data. |
| protected static Map | Returns: map of PAX headers values found inside the current (local or global) PAX headers tar entry.input stream to read keys and values inputStream, final List<TarArchiveStructSparse> used in PAX Format 0.0 & 0.1, as it may appear multiple times, the sparse headers need to be stored in an array, not a map sparseHeaders, final Map<String, String> global PAX headers of the tar archive globalPaxHeaders)
Deprecated
use the four-arg version instead
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 |
| protected static Map | Returns: map of PAX headers values found inside the current (local or global) PAX headers tar entry.input stream to read keys and values inputStream, final List<TarArchiveStructSparse> used in PAX Format 0.0 & 0.1, as it may appear multiple times, the sparse headers need to be stored in an array, not a map sparseHeaders, final Map<String, String> global PAX headers of the tar archive globalPaxHeaders, final long total size of the PAX header, will be ignored if negative headerSize)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 |
| public static TarArchiveStructSparse | Returns: a parsed sparse structThe buffer from which to parse. buffer, final int The offset into the buffer from which to parse. offset)Parses the content of a PAX 1.0 sparse block. |
| private static long[] | Returns: the decimal number delimited by '\n', and the bytes read from input streamthe input stream of the tar file inputStream)For 1.X PAX Format, the sparse headers are stored in the file data block, preceding the actual file data. |
| pack-priv static List | |
| public static boolean | Returns: whether the checksum is reasonably goodtar header header)Wikipedia says: The checksum is calculated by taking the sum of the unsigned byte values of the header block with the eight checksum bytes taken to be ASCII spaces (decimal value 32). It is stored as a six digit octal number with leading zeroes followed by a NUL and then a space. Various implementations do not adhere to this format. For better compatibility, ignore leading and trailing whitespace, and get the first six digits. In addition, some historic tar implementations treated bytes as signed. Implementations typically calculate the checksum both ways, and treat it as good if either the signed or unsigned sum matches the included checksum. |
| BYTE_MASK | back to summary |
|---|---|
| private static final int BYTE_MASK | |
| DEFAULT_ENCODING | back to summary |
|---|---|
| pack-priv static final ZipEncoding DEFAULT_ENCODING | |
| FALLBACK_ENCODING | back to summary |
|---|---|
| pack-priv static final ZipEncoding FALLBACK_ENCODING Encapsulates the algorithms used up to Commons Compress 1.3 as ZipEncoding. | |
| TarUtils | back to summary |
|---|---|
| private TarUtils() Prevents instantiation. | |
| computeCheckSum | back to summary |
|---|---|
| public static long computeCheckSum(final byte[] buf) Computes the checksum of a tar entry header.
| |
| exceptionMessage | back to summary |
|---|---|
| private static String exceptionMessage(final byte[] buffer, final int offset, final int length, final int current, final byte currentByte) | |
| formatBigIntegerBinary | back to summary |
|---|---|
| private static void formatBigIntegerBinary(final long value, final byte[] buf, final int offset, final int length, final boolean negative) | |
| formatCheckSumOctalBytes | back to summary |
|---|---|
| public static int formatCheckSumOctalBytes(final long value, final byte[] buf, final int offset, final int length) Writes an octal value into a buffer.
Uses
| |
| formatLongBinary | back to summary |
|---|---|
| private static void formatLongBinary(final long value, final byte[] buf, final int offset, final int length, final boolean negative) | |
| formatLongOctalBytes | back to summary |
|---|---|
| public static int formatLongOctalBytes(final long value, final byte[] buf, final int offset, final int length) Writes an octal long integer into a buffer.
Uses
| |
| formatLongOctalOrBinaryBytes | back to summary |
|---|---|
| public static int formatLongOctalOrBinaryBytes(final long value, final byte[] buf, final int offset, final int length) Writes a long integer into a buffer as an octal string if this will fit, or as a binary number otherwise.
Uses
| |
| formatNameBytes | back to summary |
|---|---|
| public static int formatNameBytes(final String name, final byte[] buf, final int offset, final int length) Copies a name into a buffer. Copies characters from the name into the buffer starting at the specified offset. If the buffer is longer than the name, the buffer is filled with trailing NULs. If the name is longer than the buffer, the output is truncated.
| |
| formatNameBytes | back to summary |
|---|---|
| public static int formatNameBytes(final String name, final byte[] buf, final int offset, final int length, final ZipEncoding encoding) throws IOException Copies a name into a buffer. Copies characters from the name into the buffer starting at the specified offset. If the buffer is longer than the name, the buffer is filled with trailing NULs. If the name is longer than the buffer, the output is truncated.
| |
| formatOctalBytes | back to summary |
|---|---|
| public static int formatOctalBytes(final long value, final byte[] buf, final int offset, final int length) Writes an octal integer into a buffer.
Uses
| |
| formatUnsignedOctalString | back to summary |
|---|---|
| public static void formatUnsignedOctalString(final long value, final byte[] buffer, final int offset, final int length) Fills a buffer with unsigned octal number, padded with leading zeroes.
| |
| parseBinaryBigInteger | back to summary |
|---|---|
| private static long parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative) | |
| parseBinaryLong | back to summary |
|---|---|
| private static long parseBinaryLong(final byte[] buffer, final int offset, final int length, final boolean negative) | |
| parseBoolean | back to summary |
|---|---|
| public static boolean parseBoolean(final byte[] buffer, final int offset) Parses a boolean byte from a buffer. Leading spaces and NUL are ignored. The buffer may contain trailing spaces or NULs.
| |
| parseFromPAX01SparseHeaders | back to summary |
|---|---|
| protected static List 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...]"
| |
| parseName | back to summary |
|---|---|
| public static String parseName(final byte[] buffer, final int offset, final int length) Parses an entry name from a buffer. Parsing stops when a NUL is found or the buffer length is reached.
| |
| parseName | back to summary |
|---|---|
| public static String parseName(final byte[] buffer, final int offset, final int length, final ZipEncoding encoding) throws IOException Parses an entry name from a buffer. Parsing stops when a NUL is found or the buffer length is reached.
| |
| parseOctal | back to summary |
|---|---|
| public static long parseOctal(final byte[] buffer, final int offset, final int length) Parses an octal string from a buffer. Leading spaces are ignored. The buffer must contain a trailing space or NUL, and may contain an additional trailing space or NUL. The input buffer is allowed to contain all NULs, in which case the method returns 0L (this allows for missing fields). To work-around some tar implementations that insert a leading NUL this method returns 0 if it detects a leading NUL since Commons Compress 1.4.
| |
| parseOctalOrBinary | back to summary |
|---|---|
| public static long parseOctalOrBinary(final byte[] buffer, final int offset, final int length) Computes the value contained in a byte buffer. If the most significant bit of the first byte in the buffer is set, this bit is ignored and the rest of the buffer is interpreted as a binary number. Otherwise, the buffer is interpreted as an octal number as per the parseOctal function above.
| |
| parsePAX01SparseHeaders | back to summary |
|---|---|
| protected static List Deprecated use #parseFromPAX01SparseHeaders instead 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...]"
Will internally invoke
| |
| parsePAX1XSparseHeaders | back to summary |
|---|---|
| protected static List 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.
| |
| parsePaxHeaders | back to summary |
|---|---|
| protected static Map Deprecated use the four-arg version instead 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...]"
| |
| parsePaxHeaders | back to summary |
|---|---|
| protected static Map 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...]"
| |
| parseSparse | back to summary |
|---|---|
| public static TarArchiveStructSparse parseSparse(final byte[] buffer, final int offset) Parses the content of a PAX 1.0 sparse block.
| |
| readLineOfNumberForPax1X | back to summary |
|---|---|
| private static long[] readLineOfNumberForPax1X(final InputStream inputStream) throws IOException For 1.X PAX Format, the sparse headers are stored in the file data block, preceding the actual file data. It consists of a series of decimal numbers delimited by newlines.
| |
| readSparseStructs | back to summary |
|---|---|
pack-priv static List
| |
| verifyCheckSum | back to summary |
|---|---|
| public static boolean verifyCheckSum(final byte[] header) Wikipedia says: The checksum is calculated by taking the sum of the unsigned byte values of the header block with the eight checksum bytes taken to be ASCII spaces (decimal value 32). It is stored as a six digit octal number with leading zeroes followed by a NUL and then a space. Various implementations do not adhere to this format. For better compatibility, ignore leading and trailing whitespace, and get the first six digits. In addition, some historic tar implementations treated bytes as signed. Implementations typically calculate the checksum both ways, and treat it as good if either the signed or unsigned sum matches the included checksum. The return value of this method should be treated as a best-effort heuristic rather than an absolute and final truth. The checksum verification logic may well evolve over time as more special cases are encountered.
| |