private void _InitiateCurrentEntry(bool finishing)
{
// If finishing==true, this means we're initiating the entry at the time of
// Close() or PutNextEntry(). If this happens, it means no data was written
// for the entry - Write() was never called. (The usual case us to call
// _InitiateCurrentEntry(bool) from within Write().) If finishing==true,
// the entry could be either a zero-byte file or a directory.
_entriesWritten.Add(_currentEntry.FileName,_currentEntry);
_entryCount++; // could use _entriesWritten.Count, but I don't want to incur
// the cost.
if (_entryCount > 65534 && _zip64 == Zip64Option.Never)
{
_exceptionPending = true;
throw new System.InvalidOperationException("Too many entries. Consider setting ZipOutputStream.EnableZip64.");
}
// Write out the header.
//
// If finishing, and encryption is in use, then we don't want to emit the
// normal encryption header. Signal that with a cycle=99 to turn off
// encryption for zero-byte entries or directories.
//
// If finishing, then we know the stream length is zero. Else, unknown
// stream length. Passing stream length == 0 allows an optimization so as
// not to setup an encryption or deflation stream, when stream length is
// zero.
_currentEntry.WriteHeader(_outputStream, finishing ? 99 : 0);
_currentEntry.StoreRelativeOffset();
if (!_currentEntry.IsDirectory)
{
_currentEntry.WriteSecurityMetadata(_outputStream);
_currentEntry.PrepOutputStream(_outputStream,
finishing ? 0 : -1,
out _outputCounter,
out _encryptor,
out _deflater,
out _entryOutputStream);
}
_needToWriteEntryHeader = false;
}