Beispiel #1
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));
        }
Beispiel #2
0
        public void WriteTo(Stream stream)
        {
            byte[] bytes = Encodings.Ascii.GetBytes("PIAFILEVERSION_2.0,CTBVER1,compress\r\npmzlibcodec");
            stream.Write(bytes, 0, bytes.Length);
            MemoryStream memoryStream1 = new MemoryStream();

            this.method_1(new CtbFile.Class1003((Stream)memoryStream1));
            MemoryStream memoryStream2 = new MemoryStream((int)memoryStream1.Length);

            using (ZlibCompressStream zlibCompressStream = new ZlibCompressStream((Stream)memoryStream2, true))
            {
                memoryStream1.WriteTo((Stream)zlibCompressStream);
                zlibCompressStream.Flush();
            }
            uint num = CtbFile.smethod_0(memoryStream2.GetBuffer(), 0, (int)memoryStream2.Length);

            CtbFile.smethod_7(stream, num);
            CtbFile.smethod_7(stream, (uint)memoryStream1.Length);
            CtbFile.smethod_7(stream, (uint)memoryStream2.Length);
            memoryStream2.WriteTo(stream);
        }