diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2015-11-04 19:28:43 +0700 |
commit | f56fc16973d66bd9461f247e50738e55bd54de7e (patch) | |
tree | 8e84c9bd2cfc2d554b99c8045ec46de7313410fc /crypto/src/bcpg | |
parent | Port updated revocation test from Java (diff) | |
download | BouncyCastle.NET-ed25519-f56fc16973d66bd9461f247e50738e55bd54de7e.tar.xz |
Replace Close with Dispose for PORTABLE
Diffstat (limited to 'crypto/src/bcpg')
-rw-r--r-- | crypto/src/bcpg/ArmoredInputStream.cs | 11 | ||||
-rw-r--r-- | crypto/src/bcpg/ArmoredOutputStream.cs | 67 | ||||
-rw-r--r-- | crypto/src/bcpg/BcpgInputStream.cs | 11 | ||||
-rw-r--r-- | crypto/src/bcpg/BcpgOutputStream.cs | 15 |
4 files changed, 81 insertions, 23 deletions
diff --git a/crypto/src/bcpg/ArmoredInputStream.cs b/crypto/src/bcpg/ArmoredInputStream.cs index 8d17bfa62..cfbf819e0 100644 --- a/crypto/src/bcpg/ArmoredInputStream.cs +++ b/crypto/src/bcpg/ArmoredInputStream.cs @@ -504,10 +504,21 @@ namespace Org.BouncyCastle.Bcpg return pos - offset; } +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + Platform.Dispose(input); + } + base.Dispose(disposing); + } +#else public override void Close() { Platform.Dispose(input); base.Close(); } +#endif } } diff --git a/crypto/src/bcpg/ArmoredOutputStream.cs b/crypto/src/bcpg/ArmoredOutputStream.cs index 253c5d1fe..0f0d6896c 100644 --- a/crypto/src/bcpg/ArmoredOutputStream.cs +++ b/crypto/src/bcpg/ArmoredOutputStream.cs @@ -283,37 +283,60 @@ namespace Org.BouncyCastle.Bcpg * <b>Note</b>: Close() does not close the underlying stream. So it is possible to write * multiple objects using armoring to a single stream. */ - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) { - if (type != null) + if (disposing) { - if (bufPtr > 0) - { - Encode(outStream, buf, bufPtr); - } + if (type == null) + return; - DoWrite(nl + '='); + DoClose(); - int crcV = crc.Value; - - buf[0] = ((crcV >> 16) & 0xff); - buf[1] = ((crcV >> 8) & 0xff); - buf[2] = (crcV & 0xff); + type = null; + start = true; + } + base.Dispose(disposing); + } +#else + public override void Close() + { + if (type == null) + return; - Encode(outStream, buf, 3); + DoClose(); - DoWrite(nl); - DoWrite(footerStart); - DoWrite(type); - DoWrite(footerTail); - DoWrite(nl); + type = null; + start = true; - outStream.Flush(); + base.Close(); + } +#endif - type = null; - start = true; - base.Close(); + private void DoClose() + { + if (bufPtr > 0) + { + Encode(outStream, buf, bufPtr); } + + DoWrite(nl + '='); + + int crcV = crc.Value; + + buf[0] = ((crcV >> 16) & 0xff); + buf[1] = ((crcV >> 8) & 0xff); + buf[2] = (crcV & 0xff); + + Encode(outStream, buf, 3); + + DoWrite(nl); + DoWrite(footerStart); + DoWrite(type); + DoWrite(footerTail); + DoWrite(nl); + + outStream.Flush(); } private void WriteHeaderEntry( diff --git a/crypto/src/bcpg/BcpgInputStream.cs b/crypto/src/bcpg/BcpgInputStream.cs index 37c259d42..59dd548ca 100644 --- a/crypto/src/bcpg/BcpgInputStream.cs +++ b/crypto/src/bcpg/BcpgInputStream.cs @@ -247,11 +247,22 @@ namespace Org.BouncyCastle.Bcpg } } +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + Platform.Dispose(m_in); + } + base.Dispose(disposing); + } +#else public override void Close() { Platform.Dispose(m_in); base.Close(); } +#endif /// <summary> /// 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 581897ece..c786a8fc0 100644 --- a/crypto/src/bcpg/BcpgOutputStream.cs +++ b/crypto/src/bcpg/BcpgOutputStream.cs @@ -380,12 +380,25 @@ namespace Org.BouncyCastle.Bcpg } } - public override void Close() +#if PORTABLE + protected override void Disposing(bool disposing) + { + if (disposing) + { + this.Finish(); + outStr.Flush(); + Platform.Dispose(outStr); + } + base.Dispose(disposing); + } +#else + public override void Close() { this.Finish(); outStr.Flush(); Platform.Dispose(outStr); base.Close(); } +#endif } } |