コード例 #1
0
        public int Inflate(byte[] bytes, int offset, int length)
        {
            // copy bytes from output to outputbytes if we have available bytes
            // if buffer is not filled up. keep decoding until no input are available
            // if decodeBlock returns false. Throw an exception.
            int count = 0;

            UnityEngine.Debug.Log("Inflater.Inflate(...) offset " + offset + " length " + length);

            int iter = 0;

            do
            {
                int copied = output.CopyTo(bytes, offset, length);
                UnityEngine.Debug.Log("Inflater.Inflate(...) iteration " + (++iter) + ", copied " + copied + " out of an attempted " + length);

                if (copied > 0)
                {
                    if (hasFormatReader)
                    {
                        formatReader.UpdateWithBytesRead(bytes, offset, copied);
                    }

                    offset += copied;
                    count  += copied;
                    length -= copied;
                }

                if (length == 0)     // filled in the bytes array
                {
                    break;
                }
                // Decode will return false when more input is needed
            } while (!Finished() && Decode());

            if (state == InflaterState.VerifyingFooter)    // finished reading CRC
            // In this case finished is true and output window has all the data.
            // But some data in output window might not be copied out.
            {
                if (output.AvailableBytes == 0)
                {
                    formatReader.Validate();
                }
            }

            return(count);
        }
コード例 #2
0
        public int Inflate(byte[] bytes, int offset, int length)
        {
            // copy bytes from output to outputbytes if we have aviable bytes
            // if buffer is not filled up. keep decoding until no input are available
            // if decodeBlock returns false. Throw an exception.
            var count = 0;

            do
            {
                var copied = output.CopyTo(bytes, offset, length);
                if (copied > 0)
                {
                    if (hasFormatReader)
                    {
                        formatReader.UpdateWithBytesRead(bytes, offset, copied);
                    }

                    offset += copied;
                    count  += copied;
                    length -= copied;
                }

                if (length == 0)
                {
                    break;
                }
                // Decode will return false when more input is needed
            } while (!Finished() && Decode());

            if (state == InflaterState.VerifyingFooter)
            {
                if (output.AvailableBytes == 0)
                {
                    formatReader.Validate();
                }
            }

            return(count);
        }