bool VerifyFile() { FileInfo fileinfo = new FileInfo(gamefile); if (fileinfo.Length != 2527744) { SetStatus("Wrong filesize", true); return false; } else { const UInt32 originalCRC = 0x8DAEDE7C; const UInt32 firtpartCRC = 0x56126683; bool makebackup = false; bool goodfile = false; bool original = false; UInt32 crc = new CRC().CheckCRC32(gamefile, fileinfo.Length); if (crc == originalCRC) { SetStatus("Original file", false); goodfile = original = true; } else { crc = new CRC().CheckCRC32(gamefile, 0x64BCF); if (crc == firtpartCRC) { SetStatus("Modified file", false); goodfile = true; } else SetStatus("Unknown file", true); } if (File.Exists(gamebackup)) { FileInfo backupinfo = new FileInfo(gamebackup); if (backupinfo.Length != 2527744) makebackup = true; else { UInt32 backupCRC = new CRC().CheckCRC32(gamebackup, backupinfo.Length); if (backupCRC != originalCRC) makebackup = true; } } else makebackup = true; if (original && makebackup) File.Copy(gamefile, gamebackup, true); if (makebackup) { Restore.Opacity = 0.5; Restore.IsEnabled = false; } else { Restore.Opacity = 1.0; Restore.IsEnabled = true; } return goodfile; } }
bool VerifyFile() { FileInfo fileinfo = new FileInfo(gamefile); if (fileinfo.Length != 2527744) { SetStatus("Wrong filesize", true); return(false); } else { const UInt32 originalCRC = 0x8DAEDE7C; const UInt32 firtpartCRC = 0x56126683; bool makebackup = false; bool goodfile = false; bool original = false; UInt32 crc = new CRC().CheckCRC32(gamefile, fileinfo.Length); if (crc == originalCRC) { SetStatus("Original file", false); goodfile = original = true; } else { crc = new CRC().CheckCRC32(gamefile, 0x64BCF); if (crc == firtpartCRC) { SetStatus("Modified file", false); goodfile = true; } else { SetStatus("Unknown file", true); } } if (File.Exists(gamebackup)) { FileInfo backupinfo = new FileInfo(gamebackup); if (backupinfo.Length != 2527744) { makebackup = true; } else { UInt32 backupCRC = new CRC().CheckCRC32(gamebackup, backupinfo.Length); if (backupCRC != originalCRC) { makebackup = true; } } } else { makebackup = true; } if (original && makebackup) { File.Copy(gamefile, gamebackup, true); } if (makebackup) { Restore.Opacity = 0.5; Restore.IsEnabled = false; } else { Restore.Opacity = 1.0; Restore.IsEnabled = true; } return(goodfile); } }