Package net.lingala.zip4j.headers
Class HeaderWriter
- java.lang.Object
-
- net.lingala.zip4j.headers.HeaderWriter
-
public class HeaderWriter extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static short
AES_EXTRA_DATA_RECORD_SIZE
private byte[]
intBuff
private byte[]
longBuff
private RawIO
rawIO
private static short
ZIP64_EXTRA_DATA_RECORD_SIZE_FH
private static short
ZIP64_EXTRA_DATA_RECORD_SIZE_LFH
-
Constructor Summary
Constructors Constructor Description HeaderWriter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Zip64EndOfCentralDirectoryRecord
buildZip64EndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir)
private int
calculateExtraDataRecordsSize(FileHeader fileHeader, boolean writeZip64ExtendedInfo)
private long
countNumberOfFileHeaderEntriesOnDisk(java.util.List<FileHeader> fileHeaders, int numOfDisk)
void
finalizeZipFile(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset)
void
finalizeZipFileWithoutValidations(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset)
private int
getCurrentSplitFileCounter(java.io.OutputStream outputStream)
private long
getOffsetOfCentralDirectory(ZipModel zipModel)
private boolean
isSplitZipFile(java.io.OutputStream outputStream)
private boolean
isZip64Entry(FileHeader fileHeader)
private void
processHeaderData(ZipModel zipModel, java.io.OutputStream outputStream)
private void
updateFileSizesInLocalFileHeader(SplitOutputStream outputStream, FileHeader fileHeader)
void
updateLocalFileHeader(FileHeader fileHeader, ZipModel zipModel, SplitOutputStream outputStream)
private void
writeCentralDirectory(ZipModel zipModel, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)
private void
writeEndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)
void
writeExtendedLocalHeader(LocalFileHeader localFileHeader, java.io.OutputStream outputStream)
private void
writeFileHeader(ZipModel zipModel, FileHeader fileHeader, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)
void
writeLocalFileHeader(ZipModel zipModel, LocalFileHeader localFileHeader, java.io.OutputStream outputStream, java.nio.charset.Charset charset)
private void
writeRemainingExtraDataRecordsIfPresent(FileHeader fileHeader, java.io.OutputStream outputStream)
private void
writeZip64EndOfCentralDirectoryLocator(Zip64EndOfCentralDirectoryLocator zip64EndOfCentralDirectoryLocator, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO)
private void
writeZip64EndOfCentralDirectoryRecord(Zip64EndOfCentralDirectoryRecord zip64EndOfCentralDirectoryRecord, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO)
private void
writeZipHeaderBytes(ZipModel zipModel, java.io.OutputStream outputStream, byte[] buff, java.nio.charset.Charset charset)
-
-
-
Field Detail
-
ZIP64_EXTRA_DATA_RECORD_SIZE_LFH
private static final short ZIP64_EXTRA_DATA_RECORD_SIZE_LFH
- See Also:
- Constant Field Values
-
ZIP64_EXTRA_DATA_RECORD_SIZE_FH
private static final short ZIP64_EXTRA_DATA_RECORD_SIZE_FH
- See Also:
- Constant Field Values
-
AES_EXTRA_DATA_RECORD_SIZE
private static final short AES_EXTRA_DATA_RECORD_SIZE
- See Also:
- Constant Field Values
-
rawIO
private final RawIO rawIO
-
longBuff
private final byte[] longBuff
-
intBuff
private final byte[] intBuff
-
-
Method Detail
-
writeLocalFileHeader
public void writeLocalFileHeader(ZipModel zipModel, LocalFileHeader localFileHeader, java.io.OutputStream outputStream, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
writeExtendedLocalHeader
public void writeExtendedLocalHeader(LocalFileHeader localFileHeader, java.io.OutputStream outputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
finalizeZipFile
public void finalizeZipFile(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
finalizeZipFileWithoutValidations
public void finalizeZipFileWithoutValidations(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
updateLocalFileHeader
public void updateLocalFileHeader(FileHeader fileHeader, ZipModel zipModel, SplitOutputStream outputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
updateFileSizesInLocalFileHeader
private void updateFileSizesInLocalFileHeader(SplitOutputStream outputStream, FileHeader fileHeader) throws java.io.IOException
- Throws:
java.io.IOException
-
isSplitZipFile
private boolean isSplitZipFile(java.io.OutputStream outputStream)
-
getCurrentSplitFileCounter
private int getCurrentSplitFileCounter(java.io.OutputStream outputStream)
-
writeZipHeaderBytes
private void writeZipHeaderBytes(ZipModel zipModel, java.io.OutputStream outputStream, byte[] buff, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
processHeaderData
private void processHeaderData(ZipModel zipModel, java.io.OutputStream outputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeCentralDirectory
private void writeCentralDirectory(ZipModel zipModel, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset) throws ZipException
- Throws:
ZipException
-
writeFileHeader
private void writeFileHeader(ZipModel zipModel, FileHeader fileHeader, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset) throws ZipException
- Throws:
ZipException
-
calculateExtraDataRecordsSize
private int calculateExtraDataRecordsSize(FileHeader fileHeader, boolean writeZip64ExtendedInfo)
-
writeRemainingExtraDataRecordsIfPresent
private void writeRemainingExtraDataRecordsIfPresent(FileHeader fileHeader, java.io.OutputStream outputStream) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZip64EndOfCentralDirectoryRecord
private void writeZip64EndOfCentralDirectoryRecord(Zip64EndOfCentralDirectoryRecord zip64EndOfCentralDirectoryRecord, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO) throws java.io.IOException
- Throws:
java.io.IOException
-
writeZip64EndOfCentralDirectoryLocator
private void writeZip64EndOfCentralDirectoryLocator(Zip64EndOfCentralDirectoryLocator zip64EndOfCentralDirectoryLocator, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO) throws java.io.IOException
- Throws:
java.io.IOException
-
writeEndOfCentralDirectoryRecord
private void writeEndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset) throws java.io.IOException
- Throws:
java.io.IOException
-
countNumberOfFileHeaderEntriesOnDisk
private long countNumberOfFileHeaderEntriesOnDisk(java.util.List<FileHeader> fileHeaders, int numOfDisk) throws ZipException
- Throws:
ZipException
-
isZip64Entry
private boolean isZip64Entry(FileHeader fileHeader)
-
getOffsetOfCentralDirectory
private long getOffsetOfCentralDirectory(ZipModel zipModel)
-
buildZip64EndOfCentralDirectoryRecord
private Zip64EndOfCentralDirectoryRecord buildZip64EndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir) throws ZipException
- Throws:
ZipException
-
-