fix writing the number of entries to the EOCD record
@@ -1485,7 +1485,9 @@ protected void writeCentralDirectoryEnd() throws IOException {
}
// total number of entries in the central directory on this disk
- int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk);
+ int numOfEntriesOnThisDisk = isSplitZip
+ ? (numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk))
+ : numberOfEntries;
final byte[] numOfEntriesOnThisDiskData = ZipShort
.getBytes(Math.min(numOfEntriesOnThisDisk, ZIP64_MAGIC_SHORT));
writeCounted(numOfEntriesOnThisDiskData);
@@ -1568,9 +1570,10 @@ protected void writeZip64CentralDirectory() throws IOException {
writeOut(ZipLong.getBytes(cdDiskNumberStart));
// total number of entries in the central directory on this disk
- int numOfEntriesOnThisDisk = numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk);
- final byte[] numOfEntriesOnThisDiskData = ZipEightByteInteger
- .getBytes(Math.min(numOfEntriesOnThisDisk, ZIP64_MAGIC_SHORT));
+ int numOfEntriesOnThisDisk = isSplitZip
+ ? (numberOfCDInDiskData.get(numberOfThisDisk) == null ? 0 : numberOfCDInDiskData.get(numberOfThisDisk))
+ : entries.size();
+ final byte[] numOfEntriesOnThisDiskData = ZipEightByteInteger.getBytes(numOfEntriesOnThisDisk);
writeOut(numOfEntriesOnThisDiskData);
// number of entries
