Exemplo n.º 1
0
        private void ReadFrom(Stream stream)
        {
            byte[] buffer = new byte[System.Math.Max(4, this.byte_0.Length)];
            stream.Read(buffer, 0, this.byte_0.Length);
            for (int index = 0; index < this.byte_0.Length; ++index)
            {
                if ((int)this.byte_0[index] != (int)buffer[index])
                {
                    throw new IOException("Not a WWF file: wrong magic header!");
                }
            }
            this.byte_1 = (byte)stream.ReadByte();
            switch (this.byte_1)
            {
            case 1:
                this.method_1(stream, buffer);
                break;

            case 2:
                using (ZlibDecompressStream decompressStream = new ZlibDecompressStream(stream, true))
                {
                    this.method_1((Stream)decompressStream, buffer);
                    break;
                }

            default:
                throw new IOException("Cannot handle WWF format version " + (object)this.byte_1 + "!");
            }
        }
Exemplo n.º 2
0
        public void ReadFrom(Stream stream)
        {
            byte[] numArray1 = new byte["PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec".Length];
            if (stream.Read(numArray1, 0, numArray1.Length) != numArray1.Length)
            {
                throw new IOException("CTB file format error: Wrong header!");
            }
            if ("PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec" != Encodings.Ascii.GetString(numArray1, 0, numArray1.Length))
            {
                throw new IOException("CTB file format error: Wrong header!");
            }
            int  num1 = (int)CtbFile.smethod_8(stream);
            uint num2 = CtbFile.smethod_8(stream);

            byte[] numArray2 = new byte[(IntPtr)CtbFile.smethod_8(stream)];
            if (numArray2.Length != stream.Read(numArray2, 0, numArray2.Length))
            {
                throw new IOException("CTB file format error: Compressed content is too short!");
            }
            byte[] numArray3 = new byte[(IntPtr)num2];
            using (ZlibDecompressStream decompressStream = new ZlibDecompressStream((Stream) new MemoryStream(numArray2)))
            {
                if (numArray3.Length != decompressStream.Read(numArray3, 0, numArray3.Length))
                {
                    throw new IOException("CTB file format error: Expanded content is too short!");
                }
            }
            int num3 = (int)CtbFile.smethod_0(numArray2, 0, numArray2.Length);

            this.method_0(Encodings.Ascii.GetString(numArray3, 0, numArray3.Length));
        }