/// <summary> /// Read Pak Header and FAT /// </summary> /// <returns>Returns true if the read information makes a valid pakfile</returns> protected bool ReadHeader() { files.Clear(); extraFiles.Clear(); folders.Clear(); // Read the last 512 bytes as raw header data _gpFileStream.Seek(-_header.Size, SeekOrigin.End); // Mark correct location as header offset location _gpFileStream.Read(_header.rawData, 0, _header.Size); // We don't need to read the entire thing, just the first 32 bytes contain data // _gpFileStream.Read(_header.rawData, 0, _header.Size); _header.DecryptHeaderData(); if (_header.isValid) { // Only allow editing for TypeA // if (PakType != PakFileType.PakTypeA) readOnly = true; _header.LoadRawFAT(); _header.ReadFileTable(); } else { _header.FAT.SetLength(0); } return(_header.isValid); }
/// <summary> /// Read Pak Header /// </summary> /// <returns></returns> protected bool ReadHeader() { files.Clear(); extraFiles.Clear(); folders.Clear(); // Read the last 512 bytes as raw header data _gpFileStream.Seek(-_header.Size, SeekOrigin.End); // Mark correct location as header offset location _gpFileStream.Read(_header.rawData, 0, 0x20); // We don't need to read the entire thing, just the first 32 bytes contain data // _gpFileStream.Read(_header.rawData, 0, _header.Size); _header.DecryptHeaderData(); // A valid header/footer starts with "WIBO" after decryption _header.isValid = (_header.data[0] == 'W') && (_header.data[1] == 'I') && (_header.data[2] == 'B') && (_header.data[3] == 'O'); if (_header.isValid) { _header.LoadFAT(); _header.ReadFileTable(); } else { _header.FAT.SetLength(0); } return(_header.isValid); }