inflate() public method

public inflate ( int f ) : int
f int
return int
Esempio n. 1
0
        public virtual void Finish()
        {
            do
            {
                z.next_out       = buf;
                z.next_out_index = 0;
                z.avail_out      = buf.Length;

                int err = compress
                                        ?       z.deflate(JZlib.Z_FINISH)
                                        :       z.inflate(JZlib.Z_FINISH);

                if (err != JZlib.Z_STREAM_END && err != JZlib.Z_OK)
                {
                    // TODO
//					throw new ZStreamException((compress?"de":"in")+"flating: "+z.msg);
                    throw new IOException((compress ? "de" : "in") + "flating: " + z.msg);
                }

                int count = buf.Length - z.avail_out;
                if (count > 0)
                {
                    output.Write(buf, 0, count);
                }
            }while (z.avail_in > 0 || z.avail_out == 0);

            Flush();
        }
Esempio n. 2
0
 public virtual void Finish()
 {
     do
     {
         z.next_out       = buf;
         z.next_out_index = 0;
         z.avail_out      = buf.Length;
         int num = (!compress) ? z.inflate(4) : z.deflate(4);
         if (num != 1 && num != 0)
         {
             throw new IOException(((!compress) ? "in" : "de") + "flating: " + z.msg);
         }
         int num2 = buf.Length - z.avail_out;
         if (num2 > 0)
         {
             output.Write(buf, 0, num2);
         }
     }while (z.avail_in > 0 || z.avail_out == 0);
     Flush();
 }
Esempio n. 3
0
 public virtual void Finish()
 {
     //IL_0083: Unknown result type (might be due to invalid IL or missing references)
     do
     {
         z.next_out       = buf;
         z.next_out_index = 0;
         z.avail_out      = buf.Length;
         int num = (compress ? z.deflate(4) : z.inflate(4));
         if (num != 1 && num != 0)
         {
             throw new IOException((compress ? "de" : "in") + "flating: " + z.msg);
         }
         int num2 = buf.Length - z.avail_out;
         if (num2 > 0)
         {
             output.Write(buf, 0, num2);
         }
     }while (z.avail_in > 0 || z.avail_out == 0);
     ((Stream)this).Flush();
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public override int Read(byte[] b, int off, int len)
        {
            //IL_00ca: Unknown result type (might be due to invalid IL or missing references)
            if (len == 0)
            {
                return(0);
            }
            z.next_out       = b;
            z.next_out_index = off;
            z.avail_out      = len;
            int num;

            do
            {
                if (z.avail_in == 0 && !nomoreinput)
                {
                    z.next_in_index = 0;
                    z.avail_in      = inp.Read(buf, 0, 4192);
                    if (z.avail_in <= 0)
                    {
                        z.avail_in  = 0;
                        nomoreinput = true;
                    }
                }
                num = z.inflate(flushLevel);
                if (nomoreinput && num == -5)
                {
                    return(0);
                }
                if (num != 0 && num != 1)
                {
                    throw new IOException("inflating: " + z.msg);
                }
                if ((nomoreinput || num == 1) && z.avail_out == len)
                {
                    return(0);
                }
            }while (z.avail_out == len && num == 0);
            return(len - z.avail_out);
        }
Esempio n. 6
0
        public override int Read(byte[] b, int off, int len)
        {
            if (len == 0)
            {
                return(0);
            }
            int err;

            z.next_out       = b;
            z.next_out_index = off;
            z.avail_out      = len;
            do
            {
                if ((z.avail_in == 0) && (!nomoreinput)) // if buffer is empty and more input is avaiable, refill it
                {
                    z.next_in_index = 0;
                    z.avail_in      = inp.Read(buf, 0, BUFSIZE);//(BUFSIZE<z.avail_out ? BUFSIZE : z.avail_out));
                    if (z.avail_in == 0)
                    {
                        z.avail_in  = 0;
                        nomoreinput = true;
                    }
                }
                err = z.inflate(flushLevel);
                if (nomoreinput && (err == JZlib.Z_BUF_ERROR))
                {
                    return(-1);
                }
                if (err != JZlib.Z_OK && err != JZlib.Z_STREAM_END)
                {
                    throw new IOException("inflating: " + z.msg);
                }
                if ((nomoreinput || err == JZlib.Z_STREAM_END) && (z.avail_out == len))
                {
                    return(0);
                }
            }while(z.avail_out == len && err == JZlib.Z_OK);
            //System.err.print("("+(len-z.avail_out)+")");
            return(len - z.avail_out);
        }