Cheats: Fixed crash when opening cheats menu with no game loaded
This commit is contained in:
parent
47ffc9c89d
commit
a69a0487b4
1 changed files with 11 additions and 9 deletions
|
@ -541,17 +541,19 @@ namespace Mesen.GUI
|
|||
{
|
||||
public static string GetMD5Hash(string filename)
|
||||
{
|
||||
var md5 = System.Security.Cryptography.MD5.Create();
|
||||
if(filename.EndsWith(".nes", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
|
||||
} else if(filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
foreach(var entry in ZipFile.OpenRead(filename).Entries) {
|
||||
if(entry.Name.EndsWith(".nes", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
return BitConverter.ToString(md5.ComputeHash(entry.Open())).Replace("-", "");
|
||||
if(File.Exists(filename)) {
|
||||
var md5 = System.Security.Cryptography.MD5.Create();
|
||||
if(filename.EndsWith(".nes", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
|
||||
} else if(filename.EndsWith(".zip", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
foreach(var entry in ZipFile.OpenRead(filename).Entries) {
|
||||
if(entry.Name.EndsWith(".nes", StringComparison.InvariantCultureIgnoreCase)) {
|
||||
return BitConverter.ToString(md5.ComputeHash(entry.Open())).Replace("-", "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
|
||||
}
|
||||
} else {
|
||||
return BitConverter.ToString(md5.ComputeHash(File.ReadAllBytes(filename))).Replace("-", "");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue