public override void Write(byte[] buffer, int offset, int count) { if (this.CRC32 != null) { System.IO.Compression.CRC32.SlurpBlock(buffer, offset, count); } if (this.enum5_0 == Stream0.Enum5.const_2) { this.enum5_0 = Stream0.Enum5.const_0; } else if (this.enum5_0 != Stream0.Enum5.const_0) { throw new ZlibException("Cannot Write after Reading."); } if (count == 0) { return; } this.z.InputBuffer = buffer; this.zlibCodec_0.NextIn = offset; this.zlibCodec_0.AvailableBytesIn = count; while (true) { this.zlibCodec_0.NextOut = 0; this.zlibCodec_0.OutputBuffer = this.workingBuffer; this.zlibCodec_0.AvailableBytesOut = this.byte_0.Length; int num = this._wantCompress ? this.zlibCodec_0.Deflate(this.flushType_0) : this.zlibCodec_0.Inflate(this.flushType_0); if (num != 0 && num != 1) { break; } this.stream_0.Write(this.byte_0, 0, this.byte_0.Length - this.zlibCodec_0.AvailableBytesOut); bool flag = this.zlibCodec_0.AvailableBytesIn == 0 && this.zlibCodec_0.AvailableBytesOut != 0; if (this.enum4_0 == Enum4.const_2 && !this._wantCompress) { flag = (this.zlibCodec_0.AvailableBytesIn == 8 && this.zlibCodec_0.AvailableBytesOut != 0); } if (flag) { return; } } throw new ZlibException((this._wantCompress ? "de" : "in") + "flating: " + this.zlibCodec_0.Message); }
public override int Read(byte[] buffer, int offset, int count) { if (this.enum5_0 == Stream0.Enum5.const_2) { if (!this.stream_0.CanRead) { throw new ZlibException("The stream is not readable."); } this.enum5_0 = Stream0.Enum5.const_1; this.z.AvailableBytesIn = 0; if (this.enum4_0 == Enum4.const_2) { this.int_1 = this.method_3(); if (this.int_1 == 0) { return(0); } } } if (this.enum5_0 != Stream0.Enum5.const_1) { throw new ZlibException("Cannot Read after Writing."); } if (count == 0) { return(0); } if (this.bool_1 && this._wantCompress) { return(0); } if (buffer == null) { throw new ArgumentNullException("buffer"); } if (count < 0) { throw new ArgumentOutOfRangeException("count"); } if (offset < buffer.GetLowerBound(0)) { throw new ArgumentOutOfRangeException("offset"); } if (offset + count > buffer.GetLength(0)) { throw new ArgumentOutOfRangeException("count"); } this.zlibCodec_0.OutputBuffer = buffer; this.zlibCodec_0.NextOut = offset; this.zlibCodec_0.AvailableBytesOut = count; this.zlibCodec_0.InputBuffer = this.workingBuffer; int num; while (true) { if (this.zlibCodec_0.AvailableBytesIn == 0 && !this.bool_1) { this.zlibCodec_0.NextIn = 0; this.zlibCodec_0.AvailableBytesIn = this.stream_0.Read(this.byte_0, 0, this.byte_0.Length); if (this.zlibCodec_0.AvailableBytesIn == 0) { this.bool_1 = true; } } num = (this._wantCompress ? this.zlibCodec_0.Deflate(this.flushType_0) : this.zlibCodec_0.Inflate(this.flushType_0)); if (this.bool_1 && num == -5) { break; } if (num != 0 && num != 1) { goto Block_17; } if (((this.bool_1 || num == 1) && this.zlibCodec_0.AvailableBytesOut == count) || this.zlibCodec_0.AvailableBytesOut <= 0 || this.bool_1) { goto IL_234; } if (num != 0) { goto Block_21; } } return(0); Block_17: throw new ZlibException(string.Format("{0}flating: rc={1} msg={2}", this._wantCompress ? "de" : "in", num, this.zlibCodec_0.Message)); Block_21: IL_234: if (this.zlibCodec_0.AvailableBytesOut > 0) { if (num != 0) { } if (this.bool_1 && this._wantCompress) { num = this.zlibCodec_0.Deflate(FlushType.Finish); if (num != 0 && num != 1) { throw new ZlibException(string.Format("Deflating: rc={0} msg={1}", num, this.zlibCodec_0.Message)); } } } num = count - this.zlibCodec_0.AvailableBytesOut; if (this.CRC32 != null) { System.IO.Compression.CRC32.SlurpBlock(buffer, offset, num); } return(num); }