Example #1
0
            public BAR(Stream stream)
            {
                var data = new byte[0x10];

                stream.Read(data, 0, data.Length);

                header.magic  = DATA.ByteToInt(data, 0, 4);
                header.count  = DATA.ByteToInt(data, 4, 4);
                header.dunno1 = DATA.ByteToInt(data, 8, 4);
                header.dunno2 = DATA.ByteToInt(data, 12, 4);

                if (header.magic != MagicCode)
                {
                    throw new InvalidDataException();
                }

                if (header.count != 0)
                {
                    entries = new Entry[header.count];
                    for (int i = 0; i < header.count; i++)
                    {
                        stream.Read(data, 0, data.Length);
                        entries[i].type     = DATA.ByteToInt(data, 0, 4);
                        entries[i].name     = DATA.ByteToInt(data, 4, 4);
                        entries[i].position = DATA.ByteToInt(data, 8, 4);
                        entries[i].size     = DATA.ByteToInt(data, 12, 4);
                    }
                }
                this.stream = stream;
            }