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 shortAES_EXTRA_DATA_RECORD_SIZEprivate byte[]intBuffprivate byte[]longBuffprivate RawIOrawIOprivate static shortZIP64_EXTRA_DATA_RECORD_SIZE_FHprivate static shortZIP64_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 Zip64EndOfCentralDirectoryRecordbuildZip64EndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir)private intcalculateExtraDataRecordsSize(FileHeader fileHeader, boolean writeZip64ExtendedInfo)private longcountNumberOfFileHeaderEntriesOnDisk(java.util.List<FileHeader> fileHeaders, int numOfDisk)voidfinalizeZipFile(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset)voidfinalizeZipFileWithoutValidations(ZipModel zipModel, java.io.OutputStream outputStream, java.nio.charset.Charset charset)private intgetCurrentSplitFileCounter(java.io.OutputStream outputStream)private longgetOffsetOfCentralDirectory(ZipModel zipModel)private booleanisSplitZipFile(java.io.OutputStream outputStream)private booleanisZip64Entry(FileHeader fileHeader)private voidprocessHeaderData(ZipModel zipModel, java.io.OutputStream outputStream)private voidupdateFileSizesInLocalFileHeader(SplitOutputStream outputStream, FileHeader fileHeader)voidupdateLocalFileHeader(FileHeader fileHeader, ZipModel zipModel, SplitOutputStream outputStream)private voidwriteCentralDirectory(ZipModel zipModel, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)private voidwriteEndOfCentralDirectoryRecord(ZipModel zipModel, int sizeOfCentralDir, long offsetCentralDir, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)voidwriteExtendedLocalHeader(LocalFileHeader localFileHeader, java.io.OutputStream outputStream)private voidwriteFileHeader(ZipModel zipModel, FileHeader fileHeader, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO, java.nio.charset.Charset charset)voidwriteLocalFileHeader(ZipModel zipModel, LocalFileHeader localFileHeader, java.io.OutputStream outputStream, java.nio.charset.Charset charset)private voidwriteRemainingExtraDataRecordsIfPresent(FileHeader fileHeader, java.io.OutputStream outputStream)private voidwriteZip64EndOfCentralDirectoryLocator(Zip64EndOfCentralDirectoryLocator zip64EndOfCentralDirectoryLocator, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO)private voidwriteZip64EndOfCentralDirectoryRecord(Zip64EndOfCentralDirectoryRecord zip64EndOfCentralDirectoryRecord, java.io.ByteArrayOutputStream byteArrayOutputStream, RawIO rawIO)private voidwriteZipHeaderBytes(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
-
-