diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs index 7deb2ac8..028dc3fb 100644 --- a/DATFromDir/DATFromDir.cs +++ b/DATFromDir/DATFromDir.cs @@ -453,7 +453,6 @@ namespace SabreTools // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes) if (_datdata.Romba) { - int neededHeaderSize = 32; string datum = Path.GetFileName(item).ToLowerInvariant(); long filesize = new FileInfo(item).Length; @@ -465,7 +464,7 @@ namespace SabreTools } // Check if the file is at least the minimum length - if (filesize < neededHeaderSize) + if (filesize < 32 /* bytes */) { _logger.Warning("Possibly corrupt file '" + item + "' with size " + Style.GetBytesReadable(filesize)); return ""; @@ -478,7 +477,7 @@ namespace SabreTools { using (BinaryReader br = new BinaryReader(itemstream)) { - header = br.ReadBytes(neededHeaderSize); + header = br.ReadBytes(32); br.BaseStream.Seek(-4, SeekOrigin.End); footer = br.ReadBytes(4); } @@ -494,14 +493,14 @@ namespace SabreTools // Only try to add if the file size is greater than 750 MiB if (filesize >= (750 * Constants.MibiByte)) { - // ISIZE is mod 4GiB, so we add that if the ISIZE is smaller than the filesize and header + // ISIZE is mod 4GiB, so we add that if the ISIZE is smaller than the filesize and greater than 1% different bool shouldfollowup = false; - if (extractedsize < (filesize - neededHeaderSize)) + if (extractedsize < filesize && (100 * extractedsize / filesize) < 99 /* percent */) { _logger.Log("mancalc - Filename: '" + Path.GetFullPath(item) + "'\nExtracted file size: " + extractedsize + ", " + Style.GetBytesReadable(extractedsize) + "\nArchive file size: " + filesize + ", " + Style.GetBytesReadable(filesize)); } - while (extractedsize < (filesize - neededHeaderSize)) + while (extractedsize < filesize && (100 * extractedsize / filesize) < 99 /* percent */) { extractedsize += (4 * Constants.GibiByte); shouldfollowup = true; diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 2defd5af..b992b5f1 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -1562,18 +1562,26 @@ Make a selection: { _logger.Warning("The path for " + file + " was too long"); } + catch (Exception ex) + { + _logger.Error(ex.ToString()); + } } } else if (File.Exists(input.Replace("\"", ""))) { try { - newInputs.Add(Path.GetFullPath(input.Replace("\"", "")) + "¬" + Path.GetFullPath(Path.GetDirectoryName(input.Replace("\"", "")))); + newInputs.Add(Path.GetFullPath(input.Replace("\"", "")) + "¬" + Path.GetDirectoryName(Path.GetFullPath(input.Replace("\"", "")))); } catch (PathTooLongException) { _logger.Warning("The path for " + input.Replace("\"", "") + " was too long"); } + catch (Exception ex) + { + _logger.Error(ex.ToString()); + } } } diff --git a/SabreHelper/RomManipulation.cs b/SabreHelper/RomManipulation.cs index 36bac943..fb030118 100644 --- a/SabreHelper/RomManipulation.cs +++ b/SabreHelper/RomManipulation.cs @@ -1390,13 +1390,18 @@ namespace SabreTools.Helper // Special logging to remove later if (rom.SHA1 == lastrom.SHA1 && rom.Size != lastrom.Size) { - logger.User("Rom SHA-1: " + lastrom.SHA1 + "\nRom Size: " + lastrom.Size + "\nNew Rom size: " + rom.Size); + logger.User("Hash duplicate found:\nRom SHA-1: " + lastrom.SHA1 + "\nRom Size: " + lastrom.Size + "\nNew Rom size: " + rom.Size); + } + if (rom.MD5 == lastrom.MD5 && rom.Size != lastrom.Size) + { + logger.User("Hash duplicate found:\nRom MD5: " + lastrom.MD5 + "\nRom Size: " + lastrom.Size + "\nNew Rom size: " + rom.Size); } // If it's a duplicate, skip adding it to the output but add any missing information if (dupefound) { - logger.Log("Rom information of found duplicate: " + rom.Game + "\t" + rom.Name + "\t" + rom.Size + "\t" + rom.CRC + "\t" + rom.MD5 + "\t" + rom.SHA1); + logger.Log("Rom information of found duplicate:\n\tGame: " + rom.Game + "\n\tRom Name:" + rom.Name + + "\n\tSize: " + rom.Size + "\n\tCRC:" + rom.CRC + "\n\tMD5:" + rom.MD5 + "\n\tSHA-1:" + rom.SHA1); savedrom = lastrom; pos = i;