-
Notifications
You must be signed in to change notification settings - Fork 6
/
ZLibStreams.cs
721 lines (625 loc) · 27.7 KB
/
ZLibStreams.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
/*
Derived from zlib header files (zlib license)
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
C# Wrapper based on zlibnet v1.3.3 (https://zlibnet.codeplex.com/)
Copyright (C) @hardon (https://www.codeplex.com/site/users/view/hardon)
Maintained by Hajin Jang
Copyright (C) 2017-2020 Hajin Jang
zlib license
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
using Joveler.DynLoader;
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// ReSharper disable UnusedMember.Global
namespace Joveler.Compression.ZLib
{
#region StreamOptions
public class ZLibCompressOptions
{
/// <summary>
/// Compression level. The Default is `ZLibCompLevel.Default`.
/// </summary>
public ZLibCompLevel Level { get; set; } = ZLibCompLevel.Default;
/// <summary>
/// The base two logarithm of the window size (the size of the history buffer).
/// It should be in the range from 9 to 15. The default value is 15.
/// Larger values of this parameter result in better compression at the expense of memory usage.
/// </summary>
/// <remarks>
/// C library allows value of 8 but it have been prohibitted in here due to multiple issues.
/// </remarks>
public ZLibWindowBits WindowBits { get; set; } = ZLibWindowBits.Default;
/// <summary>
/// Specifies how much memory should be allocated for the internal compression state.
/// 1 uses minimum memory but is slow and reduces compression ratio; 9 uses maximum memory for optimal speed.
/// The default value is 8.
/// </summary>
public ZLibMemLevel MemLevel { get; set; } = ZLibMemLevel.Default;
/// <summary>
/// Size of the internal buffer.
/// </summary>
public int BufferSize { get; set; } = DeflateStream.DefaultBufferSize;
/// <summary>
/// Whether to leave the base stream object open after disposing the zlib stream object.
/// </summary>
public bool LeaveOpen { get; set; } = false;
}
public class ZLibDecompressOptions
{
/// <summary>
/// The base two logarithm of the window size (the size of the history buffer).
/// It should be in the range from 9 to 15. The default value is 15.
/// WindowBits must be greater than or equal to the value provided when the stream was compressed, or the decompress will fail.
/// </summary>
/// <remarks>
/// For maximum compatibility, using ZLibWindowBits.Default (15) is recommended.
/// </remarks>
public ZLibWindowBits WindowBits { get; set; } = ZLibWindowBits.Default;
public int BufferSize { get; set; } = DeflateStream.DefaultBufferSize;
public bool LeaveOpen { get; set; } = false;
}
#endregion
#region DeflateStream
/// <summary>
/// The stream which compress or decompress deflate stream format.
/// </summary>
public class DeflateStream : Stream
{
#region enum Mode, Format
internal enum Mode
{
Compress,
Decompress,
}
protected enum Format
{
Deflate,
ZLib,
GZip,
BothZLibGzip, // Valid only in Decompress mode
}
#endregion
#region Fields and Properties
private readonly Mode _mode;
private readonly bool _leaveOpen;
private bool _disposed = false;
private ZStreamL32 _zs32;
private ZStreamL64 _zs64;
private GCHandle _zsPin;
private readonly int _bufferSize = DefaultBufferSize;
private int _workBufPos = 0;
private readonly byte[] _workBuf;
public Stream BaseStream { get; private set; }
public long TotalIn { get; private set; } = 0;
public long TotalOut { get; private set; } = 0;
// Const
private const int ReadDone = -1;
// Default Buffer Size
/* Benchmark - 256K is the fatest.
AMD Ryzen 5 3600 / .NET Core 3.1.13 / Windows 10.0.19042 x64 / zlib 1.2.11
| Method | BufferSize | Mean | Error | StdDev |
|------- |----------- |------------:|----------:|----------:|
| ZLib | 4096 | 3,215.4 us | 5.49 us | 4.87 us |
| ZLib | 16384 | 3,214.9 us | 15.69 us | 14.68 us |
| ZLib | 65536 | 3,219.9 us | 8.46 us | 7.91 us |
| ZLib | 262144 | 3,161.8 us | 8.99 us | 7.51 us |
| ZLib | 1048576 | 3,376.9 us | 13.43 us | 11.90 us |
| ZLib | 4194304 | 3,532.8 us | 10.05 us | 8.91 us |
*/
internal const int DefaultBufferSize = 256 * 1024;
#endregion
#region Constructor
/// <summary>
/// Create compressing DeflateStream.
/// </summary>
public DeflateStream(Stream baseStream, ZLibCompressOptions compOpts)
: this(baseStream, compOpts, Format.Deflate) { }
protected DeflateStream(Stream baseStream, ZLibCompressOptions compOpts, Format format)
{
ZLibInit.Manager.EnsureLoaded();
BaseStream = baseStream ?? throw new ArgumentNullException(nameof(baseStream));
_mode = Mode.Compress;
_disposed = false;
// Check and set compress options
_leaveOpen = compOpts.LeaveOpen;
_bufferSize = CheckBufferSize(compOpts.BufferSize);
_workBuf = new byte[_bufferSize];
int formatWindowBits = CheckFormatWindowBits(compOpts.WindowBits, _mode, format);
CheckMemLevel(compOpts.MemLevel);
// Prepare and init ZStream
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
_zs32 = new ZStreamL32();
_zsPin = GCHandle.Alloc(_zs32, GCHandleType.Pinned);
ZLibRet ret = ZLibInit.Lib.L32.DeflateInit(_zs32, compOpts.Level, formatWindowBits, compOpts.MemLevel);
ZLibException.CheckReturnValue(ret, _zs32);
break;
}
case PlatformLongSize.Long64:
{
_zs64 = new ZStreamL64();
_zsPin = GCHandle.Alloc(_zs64, GCHandleType.Pinned);
ZLibRet ret = ZLibInit.Lib.L64.DeflateInit(_zs64, compOpts.Level, formatWindowBits, compOpts.MemLevel);
ZLibException.CheckReturnValue(ret, _zs64);
break;
}
default:
throw new PlatformNotSupportedException();
}
}
/// <summary>
/// Create decompressing DeflateStream.
/// </summary>
public DeflateStream(Stream baseStream, ZLibDecompressOptions decompOpts)
: this(baseStream, decompOpts, Format.Deflate) { }
protected DeflateStream(Stream baseStream, ZLibDecompressOptions decompOpts, Format format)
{
ZLibInit.Manager.EnsureLoaded();
BaseStream = baseStream ?? throw new ArgumentNullException(nameof(baseStream));
_mode = Mode.Decompress;
_disposed = false;
// Check and set decompress options
_leaveOpen = decompOpts.LeaveOpen;
_bufferSize = CheckBufferSize(decompOpts.BufferSize);
_workBuf = new byte[_bufferSize];
int windowBits = CheckFormatWindowBits(decompOpts.WindowBits, _mode, format);
// Prepare and init ZStream
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
_zs32 = new ZStreamL32();
_zsPin = GCHandle.Alloc(_zs32, GCHandleType.Pinned);
ZLibRet ret = ZLibInit.Lib.L32.InflateInit(_zs32, windowBits);
ZLibException.CheckReturnValue(ret, _zs32);
break;
}
case PlatformLongSize.Long64:
{
_zs64 = new ZStreamL64();
_zsPin = GCHandle.Alloc(_zs64, GCHandleType.Pinned);
ZLibRet ret = ZLibInit.Lib.L64.InflateInit(_zs64, windowBits);
ZLibException.CheckReturnValue(ret, _zs64);
break;
}
default:
throw new PlatformNotSupportedException();
}
}
#endregion
#region Disposable Pattern
~DeflateStream()
{
Dispose(false);
}
protected override void Dispose(bool disposing)
{
if (disposing && !_disposed)
{
if (BaseStream != null)
{
if (_mode == Mode.Compress)
Flush();
if (!_leaveOpen)
BaseStream.Dispose();
BaseStream = null;
}
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
if (_zs32 != null)
{
if (_mode == Mode.Compress)
ZLibInit.Lib.L32.DeflateEnd(_zs32);
else
ZLibInit.Lib.L32.InflateEnd(_zs32);
_zsPin.Free();
_zs32 = null;
}
break;
}
case PlatformLongSize.Long64:
{
if (_zs64 != null)
{
if (_mode == Mode.Compress)
ZLibInit.Lib.L64.DeflateEnd(_zs64);
else
ZLibInit.Lib.L64.InflateEnd(_zs64);
_zsPin.Free();
_zs64 = null;
}
break;
}
}
_disposed = true;
}
}
#endregion
#region Stream Methods and Properties
/// <inheritdoc />
public override int Read(byte[] buffer, int offset, int count)
{ // For Decompress
if (_mode != Mode.Decompress)
throw new NotSupportedException("Read() not supported on compression");
CheckReadWriteArgs(buffer, offset, count);
if (count == 0)
return 0;
Span<byte> span = buffer.AsSpan(offset, count);
return Read(span);
}
/// <inheritdoc />
#if NETSTANDARD2_1
public override unsafe int Read(Span<byte> span)
#else
public unsafe int Read(Span<byte> span)
#endif
{ // For Decompress
if (_mode != Mode.Decompress)
throw new NotSupportedException("Read() not supported on compression");
if (_workBufPos == ReadDone)
return 0;
int readSize = 0;
fixed (byte* readPtr = _workBuf) // [In] Compressed
fixed (byte* writePtr = span) // [Out] Will-be-decompressed
{
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
_zs32.NextIn = readPtr + _workBufPos;
_zs32.NextOut = writePtr;
_zs32.AvailOut = (uint)span.Length;
while (0 < _zs32.AvailOut)
{
if (_zs32.AvailIn == 0)
{ // Compressed Data is no longer available in array, so read more from _stream
int baseReadSize = BaseStream.Read(_workBuf, 0, _workBuf.Length);
_workBufPos = 0;
_zs32.NextIn = readPtr;
_zs32.AvailIn = (uint)baseReadSize;
TotalIn += baseReadSize;
}
uint inCount = _zs32.AvailIn;
uint outCount = _zs32.AvailOut;
// flush method for inflate has no effect
ZLibRet ret = ZLibInit.Lib.L32.Inflate(_zs32, ZLibFlush.NoFlush);
_workBufPos += (int)(inCount - _zs32.AvailIn);
readSize += (int)(outCount - _zs32.AvailOut);
if (ret == ZLibRet.StreamEnd)
{
_workBufPos = ReadDone; // magic for StreamEnd
break;
}
ZLibException.CheckReturnValue(ret, _zs32);
}
}
break;
case PlatformLongSize.Long64:
{
_zs64.NextIn = readPtr + _workBufPos;
_zs64.NextOut = writePtr;
_zs64.AvailOut = (uint)span.Length;
while (0 < _zs64.AvailOut)
{
if (_zs64.AvailIn == 0)
{ // Compressed Data is no longer available in array, so read more from _stream
int baseReadSize = BaseStream.Read(_workBuf, 0, _workBuf.Length);
_workBufPos = 0;
_zs64.NextIn = readPtr;
_zs64.AvailIn = (uint)baseReadSize;
TotalIn += baseReadSize;
}
uint inCount = _zs64.AvailIn;
uint outCount = _zs64.AvailOut;
// flush method for inflate has no effect
ZLibRet ret = ZLibInit.Lib.L64.Inflate(_zs64, ZLibFlush.NoFlush);
_workBufPos += (int)(inCount - _zs64.AvailIn);
readSize += (int)(outCount - _zs64.AvailOut);
if (ret == ZLibRet.StreamEnd)
{
_workBufPos = ReadDone; // magic for StreamEnd
break;
}
ZLibException.CheckReturnValue(ret, _zs64);
}
}
break;
}
}
TotalOut += readSize;
return readSize;
}
/// <inheritdoc />
public override void Write(byte[] buffer, int offset, int count)
{
if (_mode != Mode.Compress)
throw new NotSupportedException("Write() not supported on decompression");
CheckReadWriteArgs(buffer, offset, count);
if (count == 0)
return;
ReadOnlySpan<byte> span = buffer.AsSpan(offset, count);
Write(span);
}
/// <inheritdoc />
#if NETSTANDARD2_1
public override unsafe void Write(ReadOnlySpan<byte> span)
#else
public unsafe void Write(ReadOnlySpan<byte> span)
#endif
{
if (_mode != Mode.Compress)
throw new NotSupportedException("Write() not supported on decompression");
TotalIn += span.Length;
fixed (byte* readPtr = span) // [In] Compressed
fixed (byte* writePtr = _workBuf) // [Out] Will-be-decompressed
{
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
_zs32.NextIn = readPtr;
_zs32.AvailIn = (uint)span.Length;
_zs32.NextOut = writePtr + _workBufPos;
_zs32.AvailOut = (uint)(_workBuf.Length - _workBufPos);
while (_zs32.AvailIn != 0)
{
uint outCount = _zs32.AvailOut;
ZLibRet ret = ZLibInit.Lib.L32.Deflate(_zs32, ZLibFlush.NoFlush);
_workBufPos += (int)(outCount - _zs32.AvailOut);
if (_zs32.AvailOut == 0)
{
BaseStream.Write(_workBuf, 0, _workBuf.Length);
TotalOut += _workBuf.Length;
_workBufPos = 0;
_zs32.NextOut = writePtr;
_zs32.AvailOut = (uint)_workBuf.Length;
}
ZLibException.CheckReturnValue(ret, _zs32);
}
break;
}
case PlatformLongSize.Long64:
{
_zs64.NextIn = readPtr;
_zs64.AvailIn = (uint)span.Length;
_zs64.NextOut = writePtr + _workBufPos;
_zs64.AvailOut = (uint)(_workBuf.Length - _workBufPos);
while (_zs64.AvailIn != 0)
{
uint outCount = _zs64.AvailOut;
ZLibRet ret = ZLibInit.Lib.L64.Deflate(_zs64, ZLibFlush.NoFlush);
_workBufPos += (int)(outCount - _zs64.AvailOut);
if (_zs64.AvailOut == 0)
{
BaseStream.Write(_workBuf, 0, _workBuf.Length);
TotalOut += _workBuf.Length;
_workBufPos = 0;
_zs64.NextOut = writePtr;
_zs64.AvailOut = (uint)_workBuf.Length;
}
ZLibException.CheckReturnValue(ret, _zs64);
}
break;
}
}
}
}
/// <inheritdoc />
public override unsafe void Flush()
{
if (_mode == Mode.Decompress)
{
BaseStream.Flush();
return;
}
fixed (byte* writePtr = _workBuf)
{
switch (ZLibInit.Lib.PlatformLongSize)
{
case PlatformLongSize.Long32:
{
_zs32.NextIn = (byte*)0;
_zs32.AvailIn = 0;
_zs32.NextOut = writePtr + _workBufPos;
_zs32.AvailOut = (uint)(_workBuf.Length - _workBufPos);
ZLibRet ret = ZLibRet.Ok;
while (ret != ZLibRet.StreamEnd)
{
if (_zs32.AvailOut != 0)
{
uint outCount = _zs32.AvailOut;
ret = ZLibInit.Lib.L32.Deflate(_zs32, ZLibFlush.Finish);
_workBufPos += (int)(outCount - _zs32.AvailOut);
if (ret != ZLibRet.StreamEnd && ret != ZLibRet.Ok)
throw new ZLibException(ret, _zs32.LastErrorMsg);
}
BaseStream.Write(_workBuf, 0, _workBufPos);
TotalOut += _workBufPos;
_workBufPos = 0;
_zs32.NextOut = writePtr;
_zs32.AvailOut = (uint)_workBuf.Length;
}
break;
}
case PlatformLongSize.Long64:
{
_zs64.NextIn = (byte*)0;
_zs64.AvailIn = 0;
_zs64.NextOut = writePtr + _workBufPos;
_zs64.AvailOut = (uint)(_workBuf.Length - _workBufPos);
ZLibRet ret = ZLibRet.Ok;
while (ret != ZLibRet.StreamEnd)
{
if (_zs64.AvailOut != 0)
{
uint outCount = _zs64.AvailOut;
ret = ZLibInit.Lib.L64.Deflate(_zs64, ZLibFlush.Finish);
_workBufPos += (int)(outCount - _zs64.AvailOut);
if (ret != ZLibRet.StreamEnd && ret != ZLibRet.Ok)
throw new ZLibException(ret, _zs64.LastErrorMsg);
}
BaseStream.Write(_workBuf, 0, _workBufPos);
TotalOut += _workBufPos;
_workBufPos = 0;
_zs64.NextOut = writePtr;
_zs64.AvailOut = (uint)_workBuf.Length;
}
break;
}
}
}
BaseStream.Flush();
}
/// <inheritdoc />
public override bool CanRead => _mode == Mode.Decompress && BaseStream.CanRead;
/// <inheritdoc />
public override bool CanWrite => _mode == Mode.Compress && BaseStream.CanWrite;
/// <inheritdoc />
public override bool CanSeek => false;
/// <inheritdoc />
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException("Seek() not supported");
}
/// <inheritdoc />
public override void SetLength(long value)
{
throw new NotSupportedException("SetLength not supported");
}
/// <inheritdoc />
public override long Length => throw new NotSupportedException("Length not supported");
/// <inheritdoc />
public override long Position
{
get => throw new NotSupportedException("Position not supported");
set => throw new NotSupportedException("Position not supported");
}
public double CompressionRatio
{
get
{
if (_mode == Mode.Compress)
{
if (TotalIn == 0)
return 0;
return 100 - TotalOut * 100.0 / TotalIn;
}
else
{
if (TotalOut == 0)
return 0;
return 100 - TotalIn * 100.0 / TotalOut;
}
}
}
#endregion
#region (internal, private) Check Arguments
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static void CheckReadWriteArgs(byte[] buffer, int offset, int count)
{
if (buffer == null)
throw new ArgumentNullException(nameof(buffer));
if (offset < 0)
throw new ArgumentOutOfRangeException(nameof(offset));
if (count < 0)
throw new ArgumentOutOfRangeException(nameof(count));
if (buffer.Length - offset < count)
throw new ArgumentOutOfRangeException(nameof(count));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int CheckBufferSize(int bufferSize)
{
if (bufferSize < 0)
throw new ArgumentOutOfRangeException(nameof(bufferSize));
return Math.Max(bufferSize, 4096);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int CheckFormatWindowBits(ZLibWindowBits windowBits, Mode mode, Format format)
{
if (!Enum.IsDefined(typeof(ZLibWindowBits), windowBits))
throw new ArgumentOutOfRangeException(nameof(windowBits));
int bits = (int)windowBits;
switch (format)
{
case Format.Deflate:
return bits * -1;
case Format.GZip:
return bits += 16;
case Format.ZLib:
return bits;
case Format.BothZLibGzip:
if (mode == Mode.Decompress)
return bits += 32;
else
throw new ArgumentException(nameof(format));
default:
throw new ArgumentException(nameof(format));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void CheckMemLevel(ZLibMemLevel memLevel)
{
if (!Enum.IsDefined(typeof(ZLibMemLevel), memLevel))
throw new ArgumentOutOfRangeException(nameof(memLevel));
}
#endregion
}
#endregion
#region ZLibStream
/// <inheritdoc />
/// /// <summary>
/// The stream which compress or decompress zlib stream format.
/// </summary>
public class ZLibStream : DeflateStream
{
/// <summary>
/// Create compressing ZLibStream.
/// </summary>
public ZLibStream(Stream baseStream, ZLibCompressOptions compOpts)
: base(baseStream, compOpts, Format.ZLib) { }
/// <summary>
/// Create decompressing ZLibStream.
/// </summary>
public ZLibStream(Stream baseStream, ZLibDecompressOptions decompOpts)
: base(baseStream, decompOpts, Format.ZLib) { }
}
#endregion
#region GZipStream
/// <inheritdoc />
/// /// <summary>
/// The stream which compress or decompress gzip stream format.
/// </summary>
public class GZipStream : DeflateStream
{
/// <summary>
/// Create compressing GZipStream.
/// </summary>
public GZipStream(Stream baseStream, ZLibCompressOptions compOpts)
: base(baseStream, compOpts, Format.GZip) { }
/// <summary>
/// Create decompressing GZipStream.
/// </summary>
public GZipStream(Stream baseStream, ZLibDecompressOptions decompOpts)
: base(baseStream, decompOpts, Format.GZip) { }
}
#endregion
}