mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Stats] Make Stat collection and output more safe
This commit is contained in:
@@ -1621,14 +1621,23 @@ namespace SabreTools.Helper
|
|||||||
/// Take an arbitrarily bucketed Dictionary and return one sorted by Game
|
/// Take an arbitrarily bucketed Dictionary and return one sorted by Game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dict">Input unsorted dictionary</param>
|
/// <param name="dict">Input unsorted dictionary</param>
|
||||||
/// <param name="mergeRoms">True if roms should be deduped, false otherwise</param>
|
/// <param name="mergeroms">True if roms should be deduped, false otherwise</param>
|
||||||
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
|
/// <param name="norename">True if games should only be compared on game and file name, false if system and source are counted</param>
|
||||||
/// <param name="logger">Logger object for file and console output</param>
|
/// <param name="logger">Logger object for file and console output</param>
|
||||||
|
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
|
||||||
/// <returns>SortedDictionary bucketed by game name</returns>
|
/// <returns>SortedDictionary bucketed by game name</returns>
|
||||||
public static SortedDictionary<string, List<RomData>> BucketByGame(Dictionary<string, List<RomData>> dict, bool mergeroms, bool norename, Logger logger)
|
public static SortedDictionary<string, List<RomData>> BucketByGame(Dictionary<string, List<RomData>> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
|
||||||
{
|
{
|
||||||
SortedDictionary<string, List<RomData>> sortable = new SortedDictionary<string, List<RomData>>();
|
SortedDictionary<string, List<RomData>> sortable = new SortedDictionary<string, List<RomData>>();
|
||||||
long count = 0;
|
long count = 0;
|
||||||
|
|
||||||
|
// If we have a null dict or an empty one, output a new dictionary
|
||||||
|
if (dict == null || dict.Count == 0)
|
||||||
|
{
|
||||||
|
return sortable;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process each all of the roms
|
||||||
foreach (List<RomData> roms in dict.Values)
|
foreach (List<RomData> roms in dict.Values)
|
||||||
{
|
{
|
||||||
List<RomData> newroms = roms;
|
List<RomData> newroms = roms;
|
||||||
@@ -1654,7 +1663,12 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.User("A total of " + count + " file hashes will be written out to file");
|
// Output the count if told to
|
||||||
|
if (output)
|
||||||
|
{
|
||||||
|
logger.User("A total of " + count + " file hashes will be written out to file");
|
||||||
|
}
|
||||||
|
|
||||||
return sortable;
|
return sortable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace SabreTools
|
|||||||
List<String> games = new List<String>();
|
List<String> games = new List<String>();
|
||||||
DatData datdata = new DatData();
|
DatData datdata = new DatData();
|
||||||
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
datdata = DatTools.Parse(filename, 0, 0, datdata, _logger);
|
||||||
SortedDictionary<string, List<RomData>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger);
|
SortedDictionary<string, List<RomData>> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false);
|
||||||
|
|
||||||
// Output single DAT stats (if asked)
|
// Output single DAT stats (if asked)
|
||||||
if (_single)
|
if (_single)
|
||||||
@@ -62,7 +62,7 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.User("\nAdding stats for file '" + filename + "'");
|
_logger.User("Adding stats for file '" + filename + "'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add single DAT stats to totals
|
// Add single DAT stats to totals
|
||||||
|
|||||||
@@ -510,7 +510,6 @@ namespace SabreTools
|
|||||||
/// <param name="currentMissingMerged">Old-current missing DAT with merged and deduped values</param>
|
/// <param name="currentMissingMerged">Old-current missing DAT with merged and deduped values</param>
|
||||||
/// <param name="currentNewMerged">New-current DAT with merged and deduped values</param>
|
/// <param name="currentNewMerged">New-current DAT with merged and deduped values</param>
|
||||||
/// <param name="fake">True if all values should be replaced with default 0-byte values, false otherwise</param>
|
/// <param name="fake">True if all values should be replaced with default 0-byte values, false otherwise</param>
|
||||||
/// <param name="logger"></param>
|
|
||||||
private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake)
|
private static void InitOfflineMerge(string currentAllMerged, string currentMissingMerged, string currentNewMerged, bool fake)
|
||||||
{
|
{
|
||||||
// Sanitize the inputs
|
// Sanitize the inputs
|
||||||
|
|||||||
Reference in New Issue
Block a user