mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Stats writing not inherent to writing to file
This commit is contained in:
@@ -3423,17 +3423,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Set the output directory (current directory on null)</param>
|
/// <param name="outDir">Set the output directory (current directory on null)</param>
|
||||||
/// <param name="norename">True if games should only be compared on game and file name (default), false if system and source are counted</param>
|
/// <param name="norename">True if games should only be compared on game and file name (default), false if system and source are counted</param>
|
||||||
/// <param name="stats">True if DAT statistics should be output on write, false otherwise (default)</param>
|
|
||||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||||
/// <param name="overwrite">True if files should be overwritten (default), false if they should be renamed instead</param>
|
/// <param name="overwrite">True if files should be overwritten (default), false if they should be renamed instead</param>
|
||||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
||||||
public bool Write(string outDir,
|
public bool Write(string outDir, bool norename = true, bool ignoreblanks = false, bool overwrite = true, bool throwOnError = false)
|
||||||
bool norename = true,
|
|
||||||
bool stats = false,
|
|
||||||
bool ignoreblanks = false,
|
|
||||||
bool overwrite = true,
|
|
||||||
bool throwOnError = false)
|
|
||||||
{
|
{
|
||||||
// If we have nothing writable, abort
|
// If we have nothing writable, abort
|
||||||
if (!HasWritable())
|
if (!HasWritable())
|
||||||
@@ -3455,18 +3449,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Make sure that the three essential fields are filled in
|
// Make sure that the three essential fields are filled in
|
||||||
EnsureHeaderFields();
|
EnsureHeaderFields();
|
||||||
|
|
||||||
// Output initial statistics, for kicks
|
|
||||||
if (stats)
|
|
||||||
{
|
|
||||||
if (Items.RomCount + Items.DiskCount == 0)
|
|
||||||
Items.RecalculateStats();
|
|
||||||
|
|
||||||
Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
|
||||||
|
|
||||||
var consoleOutput = BaseReport.Create(StatReportFormat.None, null, true, true);
|
|
||||||
consoleOutput.ReplaceStatistics(Header.FileName, Items.Keys.Count(), Items);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bucket roms by game name, if not already
|
// Bucket roms by game name, if not already
|
||||||
Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: norename);
|
Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: norename);
|
||||||
|
|
||||||
@@ -3504,6 +3486,20 @@ namespace SabreTools.Library.DatFiles
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write the stats out to console for the current DatFile
|
||||||
|
/// </summary>
|
||||||
|
public void WriteStatsToConsole()
|
||||||
|
{
|
||||||
|
if (Items.RomCount + Items.DiskCount == 0)
|
||||||
|
Items.RecalculateStats();
|
||||||
|
|
||||||
|
Items.BucketBy(Field.Machine_Name, DedupeType.None, norename: true);
|
||||||
|
|
||||||
|
var consoleOutput = BaseReport.Create(StatReportFormat.None, null, true, true);
|
||||||
|
consoleOutput.ReplaceStatistics(Header.FileName, Items.Keys.Count(), Items);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create and open an output file for writing direct from a dictionary
|
/// Create and open an output file for writing direct from a dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ namespace SabreTools.Features
|
|||||||
datdata.VerifyGeneric(Inputs, hashOnly, quickScan, asFiles);
|
datdata.VerifyGeneric(Inputs, hashOnly, quickScan, asFiles);
|
||||||
|
|
||||||
// Now write out if there are any items left
|
// Now write out if there are any items left
|
||||||
datdata.Write(OutputDir, stats: true);
|
datdata.WriteStatsToConsole();
|
||||||
|
datdata.Write(OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Otherwise, process all DATs into the same output
|
// Otherwise, process all DATs into the same output
|
||||||
@@ -116,7 +117,8 @@ namespace SabreTools.Features
|
|||||||
datdata.VerifyGeneric(Inputs, hashOnly, quickScan, asFiles);
|
datdata.VerifyGeneric(Inputs, hashOnly, quickScan, asFiles);
|
||||||
|
|
||||||
// Now write out if there are any items left
|
// Now write out if there are any items left
|
||||||
datdata.Write(OutputDir, stats: true);
|
datdata.WriteStatsToConsole();
|
||||||
|
datdata.Write(OutputDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user