private Stream GetWriteStream(Stream writeStream) { counting = new CountingWritableSubStream(writeStream); Stream output = counting; switch (compressionInfo.Compression) { case ZipCompressionMethod.None: { return output; } case ZipCompressionMethod.Deflate: { return new DeflateStream(counting, CompressionMode.Compress, compressionInfo.DeflateCompressionLevel, true); } case ZipCompressionMethod.BZip2: { return new BZip2Stream(counting, CompressionMode.Compress, true); } case ZipCompressionMethod.LZMA: { counting.WriteByte(9); counting.WriteByte(20); counting.WriteByte(5); counting.WriteByte(0); LzmaStream lzmaStream = new LzmaStream(new LzmaEncoderProperties(!originalStream.CanSeek), false, counting); counting.Write(lzmaStream.Properties, 0, lzmaStream.Properties.Length); return lzmaStream; } case ZipCompressionMethod.PPMd: { counting.Write(writer.ppmdProperties.Properties, 0, 2); return new PpmdStream(writer.ppmdProperties, counting, true); } default: { throw new NotSupportedException("CompressionMethod: " + compressionInfo.Compression); } } }
private Stream GetWriteStream(Stream writeStream) { this.counting = new CountingWritableSubStream(writeStream); Stream counting = this.counting; switch (this.writer.zipCompressionInfo.Compression) { case ZipCompressionMethod.BZip2: return new BZip2Stream(this.counting, CompressionMode.Compress, true, false); case ZipCompressionMethod.LZMA: { this.counting.WriteByte(9); this.counting.WriteByte(20); this.counting.WriteByte(5); this.counting.WriteByte(0); LzmaStream stream2 = new LzmaStream(new LzmaEncoderProperties(!this.originalStream.CanSeek), false, this.counting); this.counting.Write(stream2.Properties, 0, stream2.Properties.Length); return stream2; } case ZipCompressionMethod.PPMd: this.counting.Write(this.writer.ppmdProperties.Properties, 0, 2); return new PpmdStream(this.writer.ppmdProperties, this.counting, true); case ZipCompressionMethod.None: return counting; case ZipCompressionMethod.Deflate: return new DeflateStream(this.counting, CompressionMode.Compress, this.writer.zipCompressionInfo.DeflateCompressionLevel, true); } throw new NotSupportedException("CompressionMethod: " + this.writer.zipCompressionInfo.Compression); }