예제 #1
0
        public override void Close()
        {
            if (!initdone)
            {
                doInit();            // can happen if never called write
            }
            if (closed)
            {
                return;
            }
            closed = true;
            // sigh ... no only must I close the parent stream to force a flush, but I must save a reference
            // raw stream because (apparently) Close() sets it to null (shame on you, MS developers)
            if (deflateStream != null)
            {
                deflateStream.Close();
            }
            else             // second hack: empty input?
            {
                rawStream.WriteByte(3);
                rawStream.WriteByte(0);
            }
            // add crc
            uint crcv = adler32.GetValue();

            rawStream.WriteByte((byte)((crcv >> 24) & 0xFF));
            rawStream.WriteByte((byte)((crcv >> 16) & 0xFF));
            rawStream.WriteByte((byte)((crcv >> 8) & 0xFF));
            rawStream.WriteByte((byte)((crcv) & 0xFF));
            if (!leaveOpen)
            {
                rawStream.Close();
            }
        }
 internal long GetCrctestVal() => crctest.GetValue();