Пример #1
0
        private FileInfoBTree[] LoadFileInfoBTree(EndianBinReader reader, uint offset)
        {
            reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin);
            byte childCount  = reader.ReadByte();
            uint childOffset = reader.Read3BytesUInt32();
            uint nodeCount   = reader.ReadUInt16();
            uint dataOffset  = offset + 4 + 2;
            var  objects     = new FileInfoBTree[0];
            uint indexer     = 0;

            for (int i = 0; i < nodeCount; i++)
            {
                uint keyCount           = (ushort)(Util.ExtractTwelveBits(reader, dataOffset, 0) & 0x7FF);
                uint nextNodeDataOffset =
                    (ushort)(Util.ExtractTwelveBits(reader, dataOffset, (ushort)(keyCount + 1)));
                Array.Resize(ref objects, (int)(objects.Length + keyCount));
                for (int j = 0; j < keyCount; j++)
                {
                    uint nodeOffset = Util.ExtractTwelveBits(reader, dataOffset, (uint)j + 1);
                    var  tmpOffset  = (dataOffset + nodeOffset);
                    objects[indexer] = new FileInfoBTree(reader, ref tmpOffset);
                    indexer++;
                }

                dataOffset += nextNodeDataOffset;
            }

            return(objects);
        }
Пример #2
0
        private void LoadFileIDBTree(EndianBinReader reader, ref FileIDBTree[] objects, uint offset)
        {
            uint childOffset = 0;
            uint nodeCount   = 0;
            uint ptrNodeData = 0;

            reader.BaseStream.Seek(offset, System.IO.SeekOrigin.Begin);
            byte childCount = reader.ReadByte();

            childOffset = reader.Read3BytesUInt32() + offset;
            nodeCount   = reader.ReadUInt16();
            ptrNodeData = (uint)reader.BaseStream.Position;

            if (objects == null)
            {
                objects = new FileIDBTree[0];
            }
            uint indexer = (uint)objects.Length;

            for (int i = 0; i < nodeCount; i++)
            {
                uint keyCount           = (ushort)(Util.ExtractTwelveBits(reader, ptrNodeData, 0) & 0x7FF);
                uint nextNodeDataOffset =
                    (ushort)(Util.ExtractTwelveBits(reader, ptrNodeData, (ushort)(keyCount + 1)));
                Array.Resize(ref objects, (int)(objects.Length + keyCount));
                for (int j = 0; j < keyCount; j++)
                {
                    uint nodeOffset = Util.ExtractTwelveBits(reader, ptrNodeData, (uint)j + 1);
                    var  tmpOffset  = (ptrNodeData + nodeOffset);
                    objects[indexer] = new FileIDBTree(reader, ref tmpOffset);
                    indexer++;
                }

                ptrNodeData += nextNodeDataOffset;
            }
        }