private void OpenInternal(Stream stream, bool cleanupStreamOnDispose) { _reader = new BinaryReader(stream, Encoding.UTF8); _cleanupStreamOnDispose = cleanupStreamOnDispose; UserDataHeader = ParseUserDataHeader(_reader); if (UserDataHeader == null) { throw new MpqParsingException("Invalid MPQ header. This is probably not an MPQ archive."); } ParseArchiveHeader(); SectorSize = 512 << ArchiveHeader.SectorSizeShift; var hashTableEntries = ReadTableEntires <HashTableEntry>("(hash table)", ArchiveHeader.HashTableOffset, ArchiveHeader.HashTableEntryCount); var blockTableEntries = ReadTableEntires <BlockTableEntry>("(block table)", ArchiveHeader.BlockTableOffset, ArchiveHeader.BlockTableEntryCount); BlockTable = blockTableEntries.ToList().AsReadOnly(); HashTable = new MpqHashTable(hashTableEntries.ToArray()); }
private void OpenInternal(Stream stream, bool cleanupStreamOnDispose) { _reader = new BinaryReader(stream, Encoding.UTF8); _cleanupStreamOnDispose = cleanupStreamOnDispose; UserDataHeader = ParseUserDataHeader(_reader); if (UserDataHeader == null) throw new MpqParsingException("Invalid MPQ header. This is probably not an MPQ archive."); ParseArchiveHeader(); SectorSize = 512 << ArchiveHeader.SectorSizeShift; var hashTableEntries = ReadTableEntires<HashTableEntry>("(hash table)", ArchiveHeader.HashTableOffset, ArchiveHeader.HashTableEntryCount); var blockTableEntries = ReadTableEntires<BlockTableEntry>("(block table)", ArchiveHeader.BlockTableOffset, ArchiveHeader.BlockTableEntryCount); BlockTable = blockTableEntries.ToList().AsReadOnly(); HashTable = new MpqHashTable(hashTableEntries.ToArray()); }