protected override void DoOpen()
        {
            using (CustomBinaryReader reader = new CustomBinaryReader(new FileStream(ArchivePath, FileMode.Open, FileAccess.Read)))
            {
                uint signature = reader.ReadUInt32();
                if (signature != 0x58445442)
                {
                    throw new InvalidDataException("File is not BA2");
                }

                version = reader.ReadUInt32();
                if (version > 1)
                {
                    throw new InvalidDataException("Unsupported archive file version: " + version);
                }

                type = (ArchiveType)reader.ReadUInt32();
                if (type != ArchiveType.General)
                {
                    Log.Fine("Skipping archive file which is not the general purpose type.");
                    return;
                }

                long baseOffset          = reader.BaseStream.Position;
                uint fileCount           = reader.ReadUInt32();
                long fileNameTableOffset = reader.ReadInt64();

                FileInfo[] files = new FileInfo[fileCount];
                for (int i = 0; i < fileCount; i++)
                {
                    files[i] = new FileInfo()
                    {
                        NameHash             = reader.ReadUInt32(),
                        Type                 = reader.ReadUInt32(),
                        DirectoryNameHash    = reader.ReadUInt32(),
                        Unknown1             = reader.ReadUInt32(),
                        DataOffset           = reader.ReadInt64(),
                        DataCompressedSize   = reader.ReadUInt32(),
                        DataUncompressedSize = reader.ReadUInt32(),
                        Unknown2             = reader.ReadUInt32()
                    };
                }

                reader.BaseStream.Position = fileNameTableOffset;
                for (int i = 0; i < fileCount; i++)
                {
                    ushort length = reader.ReadUInt16();
                    string path   = reader.ReadStringFixedLength(length).ToLower();

                    string dir      = Path.GetDirectoryName(path).ToLower();
                    string filename = Path.GetFileName(path).ToLower();
                    if (!sorted.ContainsKey(dir))
                    {
                        sorted.Add(dir, new SortedDictionary <string, FileInfo>());
                    }
                    sorted[dir].Add(filename, files[i]);
                }
            }
        }