private void complete()
        {
            this.storedCombinedCRC = bsGetInt();
            this.currentState      = CState.EOF;
            this.data = null;

            if (this.storedCombinedCRC != this.computedCombinedCRC)
            {
                var msg = String.Format("BZip2 CRC error (expected {0:X8}, computed {1:X8})",
                                        this.storedCombinedCRC, this.computedCombinedCRC);

                throw new IOException(msg);
            }
        }
Esempio n. 2
0
        void InitBlock()
        {
            char magic0 = bsGetUByte();
            char magic1 = bsGetUByte();
            char magic2 = bsGetUByte();
            char magic3 = bsGetUByte();
            char magic4 = bsGetUByte();
            char magic5 = bsGetUByte();

            if (magic0 == 0x17 && magic1 == 0x72 && magic2 == 0x45 &&
                magic3 == 0x38 && magic4 == 0x50 && magic5 == 0x90)
            {
                complete(); // end of file
            }
            else if (magic0 != 0x31 ||
                     magic1 != 0x41 ||
                     magic2 != 0x59 ||
                     magic3 != 0x26 ||
                     magic4 != 0x53 ||
                     magic5 != 0x59)
            {
                this.currentState = CState.EOF;
                var msg = String.Format("bad block header at offset 0x{0:X}",
                                        this.input.Position);
                throw new IOException(msg);
            }
            else
            {
                this.storedBlockCRC = bsGetInt();
                // Console.WriteLine(" stored block CRC     : {0:X8}", this.storedBlockCRC);

                this.blockRandomised = (GetBits(1) == 1);

                // Lazily allocate data
                if (this.data == null)
                {
                    this.data = new DecompressionState(this.blockSize100k);
                }

                // currBlockNo++;
                getAndMoveToFrontDecode();

                this.crc.Reset();
                this.currentState = CState.START_BLOCK;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///   Close the stream.
        /// </summary>
        public override void Close()
        {
            Stream inShadow = this.input;

            if (inShadow != null)
            {
                try
                {
                    if (!this._leaveOpen)
                    {
                        inShadow.Close();
                    }
                }
                finally
                {
                    this.data  = null;
                    this.input = null;
                }
            }
        }