Ejemplo n.º 1
0
            // Override fill() method to provide an extra "dummy" byte
            // at the end of the input stream. This is required when
            // using the "nowrap" Inflater option.
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void fill() throws java.io.IOException
            protected internal override void Fill()
            {
                if (Eof)
                {
                    throw new EOFException("Unexpected end of ZLIB input stream");
                }
                Len = @in.Read(Buf, 0, Buf.Length);
                if (Len == -1)
                {
                    Buf[0] = 0;
                    Len    = 1;
                    Eof    = true;
                }
                Inf.SetInput(Buf, 0, Len);
            }
Ejemplo n.º 2
0
        /*
         * Reads GZIP member trailer and returns true if the eos
         * reached, false if there are more (concatenated gzip
         * data set)
         */
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private boolean readTrailer() throws java.io.IOException
        private bool ReadTrailer()
        {
            InputStream @in = this.@in;
            int         n   = Inf.Remaining;

            if (n > 0)
            {
                @in = new SequenceInputStream(new ByteArrayInputStream(Buf, Len - n, n), new FilterInputStreamAnonymousInnerClassHelper(this, @in));
            }
            // Uses left-to-right evaluation order
            if ((ReadUInt(@in) != Crc.Value) || (ReadUInt(@in) != (Inf.BytesWritten & 0xffffffffL)))
            {
                // rfc1952; ISIZE is the input size modulo 2^32
                throw new ZipException("Corrupt GZIP trailer");
            }

            // If there are more bytes available in "in" or
            // the leftover in the "inf" is > 26 bytes:
            // this.trailer(8) + next.header.min(10) + next.trailer(8)
            // try concatenated case
            if ([email protected]() > 0 || n > 26)
            {
                int m = 8;                 // this.trailer
                try
                {
                    m += ReadHeader(@in);                     // next.header
                }
                catch (IOException)
                {
                    return(true);                    // ignore any malformed, do nothing
                }
                Inf.Reset();
                if (n > m)
                {
                    Inf.SetInput(Buf, Len - n + m, n - m);
                }
                return(false);
            }
            return(true);
        }