mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Logger] Logging cleanup across the board
This commit is contained in:
@@ -22,6 +22,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
public int CompareTo(object obj)
|
public int CompareTo(object obj)
|
||||||
{
|
{
|
||||||
|
Logger temp = new Logger(false, "");
|
||||||
|
temp.Start();
|
||||||
|
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Rom comp = (Rom)obj;
|
Rom comp = (Rom)obj;
|
||||||
@@ -30,23 +35,31 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
if (this.Name == comp.Name)
|
if (this.Name == comp.Name)
|
||||||
{
|
{
|
||||||
return (RomTools.IsDuplicate(this, comp) ? 0 : 1);
|
ret = (RomTools.IsDuplicate(this, comp, temp) ? 0 : 1);
|
||||||
}
|
}
|
||||||
return String.Compare(this.Name, comp.Name);
|
ret = String.Compare(this.Name, comp.Name);
|
||||||
}
|
}
|
||||||
return String.Compare(this.Game, comp.Game);
|
ret = String.Compare(this.Game, comp.Game);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
temp.Close();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(Rom other)
|
public bool Equals(Rom other)
|
||||||
{
|
{
|
||||||
|
Logger temp = new Logger(false, "");
|
||||||
|
temp.Start();
|
||||||
|
bool isdupe = RomTools.IsDuplicate(this, other, temp);
|
||||||
|
temp.Close();
|
||||||
|
|
||||||
return (this.Game == other.Game &&
|
return (this.Game == other.Game &&
|
||||||
this.Name == other.Name &&
|
this.Name == other.Name &&
|
||||||
RomTools.IsDuplicate(this, other));
|
isdupe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
archive.SaveTo(archiveFileName + ".tmp", CompressionType.Deflate);
|
archive.SaveTo(archiveFileName + ".tmp", CompressionType.Deflate);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// Don't log archive write errors
|
// Don't log archive write errors
|
||||||
}
|
}
|
||||||
@@ -412,7 +412,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
archive.SaveTo(outputArchive + ".tmp", CompressionType.Deflate);
|
archive.SaveTo(outputArchive + ".tmp", CompressionType.Deflate);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
// Don't log archive write errors
|
// Don't log archive write errors
|
||||||
}
|
}
|
||||||
@@ -542,8 +542,8 @@ namespace SabreTools.Helper
|
|||||||
string gzsize = BitConverter.ToString(footer.Reverse().ToArray()).Replace("-", string.Empty);
|
string gzsize = BitConverter.ToString(footer.Reverse().ToArray()).Replace("-", string.Empty);
|
||||||
long extractedsize = Convert.ToInt64(gzsize, 16);
|
long extractedsize = Convert.ToInt64(gzsize, 16);
|
||||||
|
|
||||||
// Only try to add if the file size is greater than 750 MiB
|
// Only try to add if the file size is greater than 600 MiB
|
||||||
if (filesize >= (750 * Constants.MibiByte))
|
if (filesize >= (600 * Constants.MibiByte))
|
||||||
{
|
{
|
||||||
// ISIZE is mod 4GiB, so we add that if the ISIZE is smaller than the filesize and greater than 1% different
|
// 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;
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace SabreTools.Helper
|
|||||||
Rom lastrom = outroms[i];
|
Rom lastrom = outroms[i];
|
||||||
|
|
||||||
// Get the duplicate status
|
// Get the duplicate status
|
||||||
dupetype = GetDuplicateStatus(rom, lastrom);
|
dupetype = GetDuplicateStatus(rom, lastrom, logger);
|
||||||
|
|
||||||
// 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 (dupetype != DupeType.None)
|
if (dupetype != DupeType.None)
|
||||||
@@ -188,9 +188,10 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="lastrom">Rom to use as a base</param>
|
/// <param name="lastrom">Rom to use as a base</param>
|
||||||
/// <param name="datdata">DAT to match against</param>
|
/// <param name="datdata">DAT to match against</param>
|
||||||
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <param name="remove">True to remove matched roms from the input, false otherwise (default)</param>
|
/// <param name="remove">True to remove matched roms from the input, false otherwise (default)</param>
|
||||||
/// <returns>List of matched RomData objects</returns>
|
/// <returns>List of matched RomData objects</returns>
|
||||||
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata, bool remove = false)
|
public static List<Rom> GetDuplicates(Rom lastrom, Dat datdata, Logger logger, bool remove = false)
|
||||||
{
|
{
|
||||||
List<Rom> output = new List<Rom>();
|
List<Rom> output = new List<Rom>();
|
||||||
|
|
||||||
@@ -208,7 +209,7 @@ namespace SabreTools.Helper
|
|||||||
List<Rom> left = new List<Rom>();
|
List<Rom> left = new List<Rom>();
|
||||||
foreach (Rom rom in roms)
|
foreach (Rom rom in roms)
|
||||||
{
|
{
|
||||||
if (IsDuplicate(rom, lastrom))
|
if (IsDuplicate(rom, lastrom, logger))
|
||||||
{
|
{
|
||||||
output.Add(rom);
|
output.Add(rom);
|
||||||
}
|
}
|
||||||
@@ -233,8 +234,9 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rom">Rom to check for duplicate status</param>
|
/// <param name="rom">Rom to check for duplicate status</param>
|
||||||
/// <param name="lastrom">Rom to use as a baseline</param>
|
/// <param name="lastrom">Rom to use as a baseline</param>
|
||||||
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
||||||
public static bool IsDuplicate(Rom rom, Rom lastrom)
|
public static bool IsDuplicate(Rom rom, Rom lastrom, Logger logger)
|
||||||
{
|
{
|
||||||
bool dupefound = false;
|
bool dupefound = false;
|
||||||
|
|
||||||
@@ -259,6 +261,12 @@ namespace SabreTools.Helper
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// More wonderful SHA-1 logging that has to be done
|
||||||
|
if (rom.SHA1 == lastrom.SHA1 && rom.Size != lastrom.Size)
|
||||||
|
{
|
||||||
|
logger.User("SHA-1 mismatch - Hash: " + rom.SHA1);
|
||||||
|
}
|
||||||
|
|
||||||
return dupefound;
|
return dupefound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,13 +275,14 @@ namespace SabreTools.Helper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rom">Current rom to check</param>
|
/// <param name="rom">Current rom to check</param>
|
||||||
/// <param name="lastrom">Last rom to check against</param>
|
/// <param name="lastrom">Last rom to check against</param>
|
||||||
|
/// <param name="logger">Logger object for console and/or file output</param>
|
||||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||||
public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom)
|
public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom, Logger logger)
|
||||||
{
|
{
|
||||||
DupeType output = DupeType.None;
|
DupeType output = DupeType.None;
|
||||||
|
|
||||||
// If we don't have a duplicate at all, return none
|
// If we don't have a duplicate at all, return none
|
||||||
if (!IsDuplicate(rom, lastrom))
|
if (!IsDuplicate(rom, lastrom, logger))
|
||||||
{
|
{
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace SabreTools.Helper
|
|||||||
/// Now process each of the input files
|
/// Now process each of the input files
|
||||||
foreach (string filename in _inputs)
|
foreach (string filename in _inputs)
|
||||||
{
|
{
|
||||||
_logger.User("Beginning stat collection for '" + filename + "'");
|
_logger.Log("Beginning stat collection for '" + filename + "'");
|
||||||
List<String> games = new List<String>();
|
List<String> games = new List<String>();
|
||||||
Dat datdata = new Dat();
|
Dat datdata = new Dat();
|
||||||
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, true);
|
List<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + input + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in foundroms)
|
foreach (Rom found in foundroms)
|
||||||
{
|
{
|
||||||
@@ -466,7 +466,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Rom> founddroms = RomTools.GetDuplicates(drom, _datdata, true);
|
List<Rom> founddroms = RomTools.GetDuplicates(drom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in founddroms)
|
foreach (Rom found in founddroms)
|
||||||
{
|
{
|
||||||
@@ -575,7 +575,7 @@ namespace SabreTools
|
|||||||
foreach (Rom rom in internalRomData)
|
foreach (Rom rom in internalRomData)
|
||||||
{
|
{
|
||||||
// Try to find the matches to the file that was found
|
// Try to find the matches to the file that was found
|
||||||
List<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, true);
|
List<Rom> foundroms = RomTools.GetDuplicates(rom, _datdata, _logger, true);
|
||||||
_logger.Log("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
_logger.Log("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!");
|
||||||
foreach (Rom found in foundroms)
|
foreach (Rom found in foundroms)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user