From aa5f3f0929c50fc942325f18ed7ae48129d4c992 Mon Sep 17 00:00:00 2001 From: Peter Dettman Date: Sat, 3 Sep 2022 00:36:40 +0700 Subject: Stream modernization --- crypto/src/bcpg/ArmoredInputStream.cs | 8 -------- crypto/src/bcpg/ArmoredOutputStream.cs | 27 ++++++--------------------- crypto/src/bcpg/BcpgInputStream.cs | 12 ------------ crypto/src/bcpg/BcpgOutputStream.cs | 10 ---------- 4 files changed, 6 insertions(+), 51 deletions(-) (limited to 'crypto/src/bcpg') diff --git a/crypto/src/bcpg/ArmoredInputStream.cs b/crypto/src/bcpg/ArmoredInputStream.cs index 224ef7d28..1c5ebd7c5 100644 --- a/crypto/src/bcpg/ArmoredInputStream.cs +++ b/crypto/src/bcpg/ArmoredInputStream.cs @@ -482,7 +482,6 @@ namespace Org.BouncyCastle.Bcpg return c; } -#if PORTABLE protected override void Dispose(bool disposing) { if (disposing) @@ -491,13 +490,6 @@ namespace Org.BouncyCastle.Bcpg } base.Dispose(disposing); } -#else - public override void Close() - { - Platform.Dispose(input); - base.Close(); - } -#endif /** * Change how the stream should react if it encounters missing CRC checksum. diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index 4a726e2dd..7f3bcc2ef 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -331,35 +331,20 @@ namespace Org.BouncyCastle.Bcpg * Note: Close() does not close the underlying stream. So it is possible to write * multiple objects using armoring to a single stream. */ -#if PORTABLE protected override void Dispose(bool disposing) { if (disposing) { - if (type == null) - return; - - DoClose(); + if (type != null) + { + DoClose(); - type = null; - start = true; + type = null; + start = true; + } } base.Dispose(disposing); } -#else - public override void Close() - { - if (type == null) - return; - - DoClose(); - - type = null; - start = true; - - base.Close(); - } -#endif private void DoClose() { diff --git a/crypto/src/bcpg/BcpgInputStream.cs b/crypto/src/bcpg/BcpgInputStream.cs index 895b03260..5aa7ae306 100644 --- a/crypto/src/bcpg/BcpgInputStream.cs +++ b/crypto/src/bcpg/BcpgInputStream.cs @@ -184,11 +184,7 @@ namespace Org.BouncyCastle.Bcpg else { PartialInputStream pis = new PartialInputStream(this, partial, bodyLen); -#if PORTABLE - Stream buf = pis; -#else Stream buf = new BufferedStream(pis); -#endif objStream = new BcpgInputStream(buf); } @@ -251,7 +247,6 @@ namespace Org.BouncyCastle.Bcpg return tag; } -#if PORTABLE protected override void Dispose(bool disposing) { if (disposing) @@ -260,13 +255,6 @@ namespace Org.BouncyCastle.Bcpg } base.Dispose(disposing); } -#else - public override void Close() - { - Platform.Dispose(m_in); - base.Close(); - } -#endif /// /// A stream that overlays our input stream, allowing the user to only read a segment of it. diff --git a/crypto/src/bcpg/BcpgOutputStream.cs b/crypto/src/bcpg/BcpgOutputStream.cs index fbce0820e..fbdd75bff 100644 --- a/crypto/src/bcpg/BcpgOutputStream.cs +++ b/crypto/src/bcpg/BcpgOutputStream.cs @@ -376,7 +376,6 @@ namespace Org.BouncyCastle.Bcpg } } -#if PORTABLE protected override void Dispose(bool disposing) { if (disposing) @@ -387,14 +386,5 @@ namespace Org.BouncyCastle.Bcpg } base.Dispose(disposing); } -#else - public override void Close() - { - this.Finish(); - outStr.Flush(); - Platform.Dispose(outStr); - base.Close(); - } -#endif } } -- cgit 1.4.1