diff options
Diffstat (limited to 'crypto/src/bcpg/ArmoredOutputStream.cs')
-rw-r--r-- | crypto/src/bcpg/ArmoredOutputStream.cs | 67 |
1 files changed, 45 insertions, 22 deletions
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( |