Пример #1
0
        public void Read(BinaryReader br)
        {
            for (; ;)
            {
                HeaderProperty hp = (HeaderProperty)br.ReadByte();
                switch (hp)
                {
                case HeaderProperty.kPackInfo:
                    PackedStreamInfo.Read(br, out PackPosition, out PackedStreams);
                    continue;

                case HeaderProperty.kUnPackInfo:
                    Folder.ReadUnPackInfo(br, out Folders);
                    continue;

                case HeaderProperty.kSubStreamsInfo:
                    Folder.ReadSubStreamsInfo(br, ref Folders);
                    continue;

                case HeaderProperty.kEnd:
                    return;

                default:
                    throw new Exception(hp.ToString());
                }
            }
        }
Пример #2
0
 public void Write(BinaryWriter bw)
 {
     bw.Write((byte)HeaderProperty.kMainStreamsInfo);
     PackedStreamInfo.Write(bw, PackPosition, PackedStreams);
     Folder.WriteUnPackInfo(bw, Folders);
     Folder.WriteSubStreamsInfo(bw, Folders);
     bw.Write((byte)HeaderProperty.kEnd);
 }
Пример #3
0
        public static void Read(BinaryReader br, out ulong packPosition, out PackedStreamInfo[] packedStreams)
        {
            packPosition = br.ReadEncodedUInt64();

            ulong numPackStreams = br.ReadEncodedUInt64();

            packedStreams = new PackedStreamInfo[numPackStreams];
            for (ulong i = 0; i < numPackStreams; i++)
            {
                packedStreams[i] = new PackedStreamInfo();
            }

            ulong streamPosition = 0;

            for (;;)
            {
                HeaderProperty hp = (HeaderProperty)br.ReadByte();
                switch (hp)
                {
                case HeaderProperty.kSize:
                    for (ulong i = 0; i < numPackStreams; i++)
                    {
                        packedStreams[i].StreamPosition = streamPosition;
                        packedStreams[i].PackedSize     = br.ReadEncodedUInt64();
                        streamPosition += packedStreams[i].PackedSize;
                    }

                    continue;

                case HeaderProperty.kCRC:
                    for (ulong i = 0; i < numPackStreams; i++)
                    {
                        packedStreams[i].Crc = br.ReadEncodedUInt64();
                    }

                    continue;

                case HeaderProperty.kEnd:
                    return;

                default:
                    throw new Exception(hp.ToString());
                }
            }
        }