public static void Copy(Stream source, Stream destination, byte[] buffer, GZipFile.CodeProgress progress) { if (source == null) { throw new ArgumentNullException("source"); } if (destination == null) { throw new ArgumentNullException("destination"); } if (buffer == null) { throw new ArgumentNullException("buffer"); } if (buffer.Length < 128) { throw new ArgumentException("Buffer is too small", "buffer"); } bool flag = true; long num = 0L; long length = source.Length; while (flag) { int num2 = source.Read(buffer, 0, buffer.Length); if (num2 > 0) { destination.Write(buffer, 0, num2); num += (long)num2; if (progress != null) { progress.SetProgressPercent(length, num); } } else { destination.Flush(); flag = false; if (progress != null) { progress.SetProgressPercent(length, length); } } } }
public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner, GZipFile.CodeProgress progress) { if (inStream == null || outStream == null) { throw new Exception("Null Stream"); } try { using (GZipInputStream gZipInputStream = new GZipInputStream(inStream)) { gZipInputStream.IsStreamOwner = isStreamOwner; StreamUtils.Copy(gZipInputStream, outStream, new byte[4096], progress); } } finally { if (isStreamOwner) { outStream.Close(); } } }
public static void Decompress(Stream inStream, Stream outStream, bool isStreamOwner, GZipFile.CodeProgress progress) { if (inStream == null || outStream == null) { throw new Exception("Null Stream"); } try { using (GZipInputStream bzipInput = new GZipInputStream(inStream)) { bzipInput.IsStreamOwner = isStreamOwner; ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(bzipInput, outStream, new byte[4096], progress); } } finally { if (isStreamOwner) { // inStream is closed by the GZipInputStream if stream owner outStream.Close(); } } }