diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-06 22:44:32 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2023-03-06 22:44:32 +0700 |
commit | 44844b4c0e0df30a72f1659b9904749f456f2545 (patch) | |
tree | d727163d1ff7d8126c640b4263aed0f041de1e8e /crypto/src/util/io | |
parent | Use Id instead of ToString (diff) | |
download | BouncyCastle.NET-ed25519-44844b4c0e0df30a72f1659b9904749f456f2545.tar.xz |
Support leaveOpen in decompressors
Diffstat (limited to 'crypto/src/util/io')
-rw-r--r-- | crypto/src/util/io/compression/Bzip2.cs | 6 | ||||
-rw-r--r-- | crypto/src/util/io/compression/ZLib.cs | 8 | ||||
-rw-r--r-- | crypto/src/util/io/compression/Zip.cs | 8 |
3 files changed, 14 insertions, 8 deletions
diff --git a/crypto/src/util/io/compression/Bzip2.cs b/crypto/src/util/io/compression/Bzip2.cs index 72b006dc9..cf84923a2 100644 --- a/crypto/src/util/io/compression/Bzip2.cs +++ b/crypto/src/util/io/compression/Bzip2.cs @@ -13,9 +13,11 @@ namespace Org.BouncyCastle.Utilities.IO.Compression : new Impl.CBZip2OutputStream(stream); } - internal static Stream DecompressInput(Stream stream) + internal static Stream DecompressInput(Stream stream, bool leaveOpen = false) { - return new Impl.CBZip2InputStream(stream); + return leaveOpen + ? new Impl.CBZip2InputStreamLeaveOpen(stream) + : new Impl.CBZip2InputStream(stream); } } } diff --git a/crypto/src/util/io/compression/ZLib.cs b/crypto/src/util/io/compression/ZLib.cs index 1254da012..b44d1106f 100644 --- a/crypto/src/util/io/compression/ZLib.cs +++ b/crypto/src/util/io/compression/ZLib.cs @@ -21,12 +21,14 @@ namespace Org.BouncyCastle.Utilities.IO.Compression #endif } - internal static Stream DecompressInput(Stream stream) + internal static Stream DecompressInput(Stream stream, bool leaveOpen = false) { #if NET6_0_OR_GREATER - return new ZLibStream(stream, CompressionMode.Decompress, leaveOpen: false); + return new ZLibStream(stream, CompressionMode.Decompress, leaveOpen); #else - return new ZInputStream(stream); + return leaveOpen + ? new ZInputStreamLeaveOpen(stream) + : new ZInputStream(stream); #endif } diff --git a/crypto/src/util/io/compression/Zip.cs b/crypto/src/util/io/compression/Zip.cs index f2773d63b..e5907c60d 100644 --- a/crypto/src/util/io/compression/Zip.cs +++ b/crypto/src/util/io/compression/Zip.cs @@ -21,12 +21,14 @@ namespace Org.BouncyCastle.Utilities.IO.Compression #endif } - internal static Stream DecompressInput(Stream stream) + internal static Stream DecompressInput(Stream stream, bool leaveOpen = false) { #if NET6_0_OR_GREATER - return new DeflateStream(stream, CompressionMode.Decompress, leaveOpen: false); + return new DeflateStream(stream, CompressionMode.Decompress, leaveOpen); #else - return new ZInputStream(stream, true); + return leaveOpen + ? new ZInputStreamLeaveOpen(stream, true) + : new ZInputStream(stream, true); #endif } } |