示例#1
0
文件: TpkCore.cs 项目: NFSTools/mwtc
 protected new void Read(BinaryReader br)
 {
     br.BaseStream.Seek(0, SeekOrigin.Begin);
     _header        = new TpkHeader();
     _header.Length = (uint)br.BaseStream.Length;
     base.Read(br);
 }
示例#2
0
文件: TpkCore.cs 项目: NFSTools/mwtc
        public override void Read(BinaryReader br)
        {
            const uint IsParentBlock = 0x80000000;

            _blocks = new ArrayList();
            long position = br.BaseStream.Position;

            while ((br.BaseStream.Position - position) < _header.Length)
            {
                TpkBase   block  = null;
                TpkHeader header = new TpkHeader();
                header.Read(br);
                long positionLocal = br.BaseStream.Position;
                if (((uint)header.Id & IsParentBlock) != 0)
                {
                    block = new TpkBaseBlock();
                }
                else
                {
                    switch (header.Id)
                    {
                    case TpkChunk.TpkHeadFileInfo:
                        block = new TpkHeadFileInfo();
                        break;

                    case TpkChunk.TpkHeadHash:
                        block = new TpkHeadHash();
                        break;

                    case TpkChunk.TpkHeadDataOffset:
                        block = new TpkHeadDataOffset();
                        break;

                    case TpkChunk.TpkDataHeadLink:
                        block = new TpkDataHeadLink();
                        break;

                    case TpkChunk.TpkDataRaw:
                        block = new TpkDataRaw();
                        break;

                    case TpkChunk.TpkNull:
                        block = new TpkNull();
                        break;

                    default:
                        block = new TpkUnknown();
                        break;
                    }
                }
                block.Header = header;
                block.Read(br);
                _blocks.Add(block);
                br.BaseStream.Seek(positionLocal + header.Length, SeekOrigin.Begin);
            }
        }