Finetuning of Romba mode as well as misc fixes for other issues related.

This commit is contained in:
Matt Nadareski
2016-06-01 22:49:02 -07:00
parent 947c6040d4
commit 945a25ea11
3 changed files with 21 additions and 9 deletions

View File

@@ -453,7 +453,6 @@ namespace SabreTools
// Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes) // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes)
if (_datdata.Romba) if (_datdata.Romba)
{ {
int neededHeaderSize = 32;
string datum = Path.GetFileName(item).ToLowerInvariant(); string datum = Path.GetFileName(item).ToLowerInvariant();
long filesize = new FileInfo(item).Length; long filesize = new FileInfo(item).Length;
@@ -465,7 +464,7 @@ namespace SabreTools
} }
// Check if the file is at least the minimum length // 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)); _logger.Warning("Possibly corrupt file '" + item + "' with size " + Style.GetBytesReadable(filesize));
return ""; return "";
@@ -478,7 +477,7 @@ namespace SabreTools
{ {
using (BinaryReader br = new BinaryReader(itemstream)) using (BinaryReader br = new BinaryReader(itemstream))
{ {
header = br.ReadBytes(neededHeaderSize); header = br.ReadBytes(32);
br.BaseStream.Seek(-4, SeekOrigin.End); br.BaseStream.Seek(-4, SeekOrigin.End);
footer = br.ReadBytes(4); footer = br.ReadBytes(4);
} }
@@ -494,14 +493,14 @@ namespace SabreTools
// Only try to add if the file size is greater than 750 MiB // Only try to add if the file size is greater than 750 MiB
if (filesize >= (750 * Constants.MibiByte)) 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; 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: " + _logger.Log("mancalc - Filename: '" + Path.GetFullPath(item) + "'\nExtracted file size: " +
extractedsize + ", " + Style.GetBytesReadable(extractedsize) + "\nArchive file size: " + filesize + ", " + Style.GetBytesReadable(filesize)); 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); extractedsize += (4 * Constants.GibiByte);
shouldfollowup = true; shouldfollowup = true;

View File

@@ -1562,18 +1562,26 @@ Make a selection:
{ {
_logger.Warning("The path for " + file + " was too long"); _logger.Warning("The path for " + file + " was too long");
} }
catch (Exception ex)
{
_logger.Error(ex.ToString());
}
} }
} }
else if (File.Exists(input.Replace("\"", ""))) else if (File.Exists(input.Replace("\"", "")))
{ {
try 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) catch (PathTooLongException)
{ {
_logger.Warning("The path for " + input.Replace("\"", "") + " was too long"); _logger.Warning("The path for " + input.Replace("\"", "") + " was too long");
} }
catch (Exception ex)
{
_logger.Error(ex.ToString());
}
} }
} }

View File

@@ -1390,13 +1390,18 @@ namespace SabreTools.Helper
// Special logging to remove later // Special logging to remove later
if (rom.SHA1 == lastrom.SHA1 && rom.Size != lastrom.Size) 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 it's a duplicate, skip adding it to the output but add any missing information
if (dupefound) 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; savedrom = lastrom;
pos = i; pos = i;