//writes eocd, and if needed, zip 64 eocd, zip64 eocd locator
//should only throw an exception in extremely exceptional cases because it is called from dispose
private void WriteArchiveEpilogue(long startOfCentralDirectory, long sizeOfCentralDirectory)
{
//determine if we need Zip 64
bool needZip64 = false;
if (startOfCentralDirectory >= uint.MaxValue ||
sizeOfCentralDirectory >= uint.MaxValue ||
_entries.Count >= ZipHelper.Mask16Bit
#if DEBUG_FORCE_ZIP64
|| _forceZip64
#endif
)
{
needZip64 = true;
}
//if we need zip 64, write zip 64 eocd and locator
if (needZip64)
{
long zip64EOCDRecordStart = _archiveStream.Position;
Zip64EndOfCentralDirectoryRecord.WriteBlock(_archiveStream, _entries.Count, startOfCentralDirectory, sizeOfCentralDirectory);
Zip64EndOfCentralDirectoryLocator.WriteBlock(_archiveStream, zip64EOCDRecordStart);
}
//write normal eocd
ZipEndOfCentralDirectoryBlock.WriteBlock(_archiveStream, _entries.Count, startOfCentralDirectory, sizeOfCentralDirectory, _archiveComment);
}