System.util.zlib.ZInputStream.Read C# (CSharp) Method

Read() public method

public Read ( byte b, int off, int len ) : int
b byte
off int
len int
return int
		public override int Read(byte[]	b, int off, int len)
		{
			if (len==0)
				return 0;

			z.next_out = b;
			z.next_out_index = off;
			z.avail_out = len;

			int err;
			do
			{
				if (z.avail_in == 0 && !nomoreinput)
				{
					// if buffer is empty and more input is available, refill it
					z.next_in_index = 0;
					z.avail_in = input.Read(buf, 0, buf.Length); //(bufsize<z.avail_out ? bufsize : z.avail_out));

					if (z.avail_in <= 0)
					{
						z.avail_in = 0;
						nomoreinput = true;
					}
				}

				err = compress
					?	z.deflate(flushLevel)
					:	z.inflate(flushLevel);

				if (nomoreinput && err == JZlib.Z_BUF_ERROR)
					return 0;
				if (err != JZlib.Z_OK && err != JZlib.Z_STREAM_END)
					// TODO
//					throw new ZStreamException((compress ? "de" : "in") + "flating: " + z.msg);
					throw new IOException((compress ? "de" : "in") + "flating: " + z.msg);
				if ((nomoreinput || err == JZlib.Z_STREAM_END) && z.avail_out == len)
					return 0;
			} 
			while(z.avail_out == len && err == JZlib.Z_OK);
			//Console.Error.WriteLine("("+(len-z.avail_out)+")");
			return len - z.avail_out;
		}