Ejemplo n.º 1
0
        public void Read(byte[] bytes)
        {
            if (bytes.Length < 276)
            {
                //Decompress
                bytes = PCKZlib.Decompress(bytes, 276);
            }
            BinaryReader br = new BinaryReader(new MemoryStream(bytes));

            Path           = Encoding.GetEncoding(936).GetString(br.ReadBytes(260)).Split(new string[] { "\0" }, StringSplitOptions.RemoveEmptyEntries)[0].Replace("/", "\\");
            Offset         = br.ReadUInt32();
            Size           = br.ReadInt32();
            CompressedSize = br.ReadInt32();
            br.Close();
        }
Ejemplo n.º 2
0
        public byte[] Write(int CompressionLevel)
        {
            byte[]       buffer = new byte[288];
            MemoryStream msb    = new MemoryStream(buffer);
            BinaryWriter bw     = new BinaryWriter(msb);

            bw.Write(Encoding.GetEncoding("GB2312").GetBytes(Path.Replace("/", "\\")));
            bw.BaseStream.Seek(260, SeekOrigin.Begin);
            bw.Write(Offset);
            bw.Write(Size);
            bw.Write(CompressedSize);
            bw.Write(0);
            bw.BaseStream.Seek(0, SeekOrigin.Begin);
            bw.Close();
            byte[] compressed = PCKZlib.Compress(buffer, CompressionLevel);
            return(compressed.Length < 288 ? compressed : buffer);
        }