public static DeflateStreamNative Create(Stream compressedStream, CompressionMode mode, bool gzip) { var dsn = new DeflateStreamNative(); dsn.data = GCHandle.Alloc(dsn); dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite(UnmanagedWrite) : new UnmanagedReadOrWrite(UnmanagedRead); dsn.z_stream = CreateZStream(mode, gzip, dsn.feeder, GCHandle.ToIntPtr(dsn.data)); if (dsn.z_stream == IntPtr.Zero) { dsn.Dispose(true); return(null); } dsn.base_stream = compressedStream; return(dsn); }
internal DeflateStream (Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip) { if (compressedStream == null) throw new ArgumentNullException ("compressedStream"); if (mode != CompressionMode.Compress && mode != CompressionMode.Decompress) throw new ArgumentException ("mode"); this.base_stream = compressedStream; this.native = DeflateStreamNative.Create (compressedStream, mode, gzip); if (this.native == null) { throw new NotImplementedException ("Failed to initialize zlib. You probably have an old zlib installed. Version 1.2.0.4 or later is required."); } this.mode = mode; this.leaveOpen = leaveOpen; }
internal DeflateStream(Stream compressedStream, CompressionMode mode, bool leaveOpen, bool gzip) { if (compressedStream == null) { throw new ArgumentNullException("compressedStream"); } if (mode != CompressionMode.Compress && mode != CompressionMode.Decompress) { throw new ArgumentException("mode"); } this.base_stream = compressedStream; this.native = DeflateStreamNative.Create(compressedStream, mode, gzip); if (this.native == null) { throw new NotImplementedException("Failed to initialize zlib. You probably have an old zlib installed. Version 1.2.0.4 or later is required."); } this.mode = mode; this.leaveOpen = leaveOpen; }
public static DeflateStreamNative Create (Stream compressedStream, CompressionMode mode, bool gzip) { var dsn = new DeflateStreamNative (); dsn.data = GCHandle.Alloc (dsn); dsn.feeder = mode == CompressionMode.Compress ? new UnmanagedReadOrWrite (UnmanagedWrite) : new UnmanagedReadOrWrite (UnmanagedRead); dsn.z_stream = CreateZStream (mode, gzip, dsn.feeder, GCHandle.ToIntPtr (dsn.data)); if (dsn.z_stream == IntPtr.Zero) { dsn.Dispose (true); return null; } dsn.base_stream = compressedStream; return dsn; }