private Stream OpenInWriteMode()
{
if (_everOpenedForWrite)
throw new IOException(SR.CreateModeWriteOnceAndOneEntryAtATime);
//we assume that if another entry grabbed the archive stream, that it set this entry's _everOpenedForWrite property to true by calling WriteLocalFileHeaderIfNeeed
Debug.Assert(_archive.IsStillArchiveStreamOwner(this));
_everOpenedForWrite = true;
CheckSumAndSizeWriteStream crcSizeStream = GetDataCompressor(_archive.ArchiveStream, true,
(object o, EventArgs e) =>
{
//release the archive stream
var entry = (ZipArchiveEntry)o;
entry._archive.ReleaseArchiveStream(entry);
entry._outstandingWriteStream = null;
});
_outstandingWriteStream = new DirectToArchiveWriterStream(crcSizeStream, this);
return new WrappedStream(baseStream: _outstandingWriteStream, closeBaseStream: true);
}