Class Zip64ExtendedInformationExtraField
java.lang.Object
org.apache.commons.compress.archivers.zip.Zip64ExtendedInformationExtraField
- All Implemented Interfaces:
ZipExtraField
Holds size and other extended information for entries that use Zip64 features.
Currently Commons Compress doesn't support encrypting the central directory so the note in APPNOTE.TXT about masking doesn't apply.
The implementation relies on data being read from the local file header and assumes that both size values are always present.
- Since:
- 1.2
- See Also:
- This class is not thread-safe
-
Field Summary
Fields inherited from interface org.apache.commons.compress.archivers.zip.ZipExtraField
EXTRAFIELD_HEADER_SIZE
-
Constructor Summary
ConstructorDescriptionThis constructor should only be used by the code that reads archives inside of Commons Compress.Zip64ExtendedInformationExtraField
(ZipEightByteInteger size, ZipEightByteInteger compressedSize) Creates an extra field based on the original and compressed size.Zip64ExtendedInformationExtraField
(ZipEightByteInteger size, ZipEightByteInteger compressedSize, ZipEightByteInteger relativeHeaderOffset, ZipLong diskStart) Creates an extra field based on all four possible values. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
The actual data to put into central directory - without Header-ID or length specifier.Length of the extra field in the central directory - without Header-ID or length specifier.The compressed size stored in this extra field.The disk start number stored in this extra field.The Header-ID.byte[]
The actual data to put into local file data - without Header-ID or length specifier.Length of the extra field in the local file data - without Header-ID or length specifier.The relative header offset stored in this extra field.getSize()
The uncompressed size stored in this extra field.void
parseFromCentralDirectoryData
(byte[] buffer, int offset, int length) Populate data from this array as if it was in central directory data.void
parseFromLocalFileData
(byte[] buffer, int offset, int length) Populate data from this array as if it was in local file data.void
reparseCentralDirectoryData
(boolean hasUncompressedSize, boolean hasCompressedSize, boolean hasRelativeHeaderOffset, boolean hasDiskStart) Parses the raw bytes read from the central directory extra field with knowledge which fields are expected to be there.void
setCompressedSize
(ZipEightByteInteger compressedSize) The uncompressed size stored in this extra field.void
The disk start number stored in this extra field.void
The relative header offset stored in this extra field.void
setSize
(ZipEightByteInteger size) The uncompressed size stored in this extra field.
-
Constructor Details
-
Zip64ExtendedInformationExtraField
public Zip64ExtendedInformationExtraField()This constructor should only be used by the code that reads archives inside of Commons Compress. -
Zip64ExtendedInformationExtraField
public Zip64ExtendedInformationExtraField(ZipEightByteInteger size, ZipEightByteInteger compressedSize) Creates an extra field based on the original and compressed size.- Parameters:
size
- the entry's original sizecompressedSize
- the entry's compressed size- Throws:
IllegalArgumentException
- if size or compressedSize is null
-
Zip64ExtendedInformationExtraField
public Zip64ExtendedInformationExtraField(ZipEightByteInteger size, ZipEightByteInteger compressedSize, ZipEightByteInteger relativeHeaderOffset, ZipLong diskStart) Creates an extra field based on all four possible values.- Parameters:
size
- the entry's original sizecompressedSize
- the entry's compressed sizerelativeHeaderOffset
- the entry's offsetdiskStart
- the disk start- Throws:
IllegalArgumentException
- if size or compressedSize is null
-
-
Method Details
-
getCentralDirectoryData
Description copied from interface:ZipExtraField
The actual data to put into central directory - without Header-ID or length specifier.- Specified by:
getCentralDirectoryData
in interfaceZipExtraField
- Returns:
- the data
-
getCentralDirectoryLength
Description copied from interface:ZipExtraField
Length of the extra field in the central directory - without Header-ID or length specifier.- Specified by:
getCentralDirectoryLength
in interfaceZipExtraField
- Returns:
- the length of the field in the central directory
-
getCompressedSize
The compressed size stored in this extra field.- Returns:
- The compressed size stored in this extra field.
-
getDiskStartNumber
The disk start number stored in this extra field.- Returns:
- The disk start number stored in this extra field.
-
getHeaderId
Description copied from interface:ZipExtraField
The Header-ID.- Specified by:
getHeaderId
in interfaceZipExtraField
- Returns:
- The HeaderId value
-
getLocalFileDataData
Description copied from interface:ZipExtraField
The actual data to put into local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataData
in interfaceZipExtraField
- Returns:
- the data
-
getLocalFileDataLength
Description copied from interface:ZipExtraField
Length of the extra field in the local file data - without Header-ID or length specifier.- Specified by:
getLocalFileDataLength
in interfaceZipExtraField
- Returns:
- the length of the field in the local file data
-
getRelativeHeaderOffset
The relative header offset stored in this extra field.- Returns:
- The relative header offset stored in this extra field.
-
getSize
The uncompressed size stored in this extra field.- Returns:
- The uncompressed size stored in this extra field.
-
parseFromCentralDirectoryData
public void parseFromCentralDirectoryData(byte[] buffer, int offset, int length) throws ZipException Description copied from interface:ZipExtraField
Populate data from this array as if it was in central directory data.- Specified by:
parseFromCentralDirectoryData
in interfaceZipExtraField
- Parameters:
buffer
- the buffer to read data fromoffset
- offset into buffer to read datalength
- the length of data- Throws:
ZipException
- on error
-
parseFromLocalFileData
Description copied from interface:ZipExtraField
Populate data from this array as if it was in local file data.- Specified by:
parseFromLocalFileData
in interfaceZipExtraField
- Parameters:
buffer
- the buffer to read data fromoffset
- offset into buffer to read datalength
- the length of data- Throws:
ZipException
- on error
-
reparseCentralDirectoryData
public void reparseCentralDirectoryData(boolean hasUncompressedSize, boolean hasCompressedSize, boolean hasRelativeHeaderOffset, boolean hasDiskStart) throws ZipException Parses the raw bytes read from the central directory extra field with knowledge which fields are expected to be there.All four fields inside the zip64 extended information extra field are optional and must only be present if their corresponding entry inside the central directory contains the correct magic value.
- Parameters:
hasUncompressedSize
- flag to read from central directoryhasCompressedSize
- flag to read from central directoryhasRelativeHeaderOffset
- flag to read from central directoryhasDiskStart
- flag to read from central directory- Throws:
ZipException
- on error
-
setCompressedSize
The uncompressed size stored in this extra field.- Parameters:
compressedSize
- The uncompressed size stored in this extra field.
-
setDiskStartNumber
The disk start number stored in this extra field.- Parameters:
ds
- The disk start number stored in this extra field.
-
setRelativeHeaderOffset
The relative header offset stored in this extra field.- Parameters:
rho
- The relative header offset stored in this extra field.
-
setSize
The uncompressed size stored in this extra field.- Parameters:
size
- The uncompressed size stored in this extra field.
-