diff options
Diffstat (limited to 'crypto/src/util/zlib/ZInputStream.cs')
-rw-r--r-- | crypto/src/util/zlib/ZInputStream.cs | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/crypto/src/util/zlib/ZInputStream.cs b/crypto/src/util/zlib/ZInputStream.cs index de1c27202..67b30a3ec 100644 --- a/crypto/src/util/zlib/ZInputStream.cs +++ b/crypto/src/util/zlib/ZInputStream.cs @@ -116,17 +116,34 @@ namespace Org.BouncyCastle.Utilities.Zlib this.z.avail_in = 0; } + protected void Detach(bool disposing) + { + if (disposing) + { + ImplDisposing(disposeInput: false); + } + base.Dispose(disposing); + } + protected override void Dispose(bool disposing) { if (disposing) { - if (!closed) + ImplDisposing(disposeInput: true); + } + base.Dispose(disposing); + } + + private void ImplDisposing(bool disposeInput) + { + if (!closed) + { + closed = true; + if (disposeInput) { - closed = true; input.Dispose(); } } - base.Dispose(disposing); } public virtual int FlushMode @@ -205,4 +222,38 @@ namespace Org.BouncyCastle.Utilities.Zlib get { return z.total_out; } } } + + public class ZInputStreamLeaveOpen + : ZInputStream + { + public ZInputStreamLeaveOpen(Stream input) + : base(input) + { + } + + public ZInputStreamLeaveOpen(Stream input, bool nowrap) + : base(input, nowrap) + { + } + + public ZInputStreamLeaveOpen(Stream input, ZStream z) + : base(input, z) + { + } + + public ZInputStreamLeaveOpen(Stream input, int level) + : base(input, level) + { + } + + public ZInputStreamLeaveOpen(Stream input, int level, bool nowrap) + : base(input, level, nowrap) + { + } + + protected override void Dispose(bool disposing) + { + Detach(disposing); + } + } } |