Create passthrough methods for scaffolding

This commit is contained in:
Matt Nadareski
2025-01-12 23:15:30 -05:00
parent d80a6b173c
commit f4743e859e
18 changed files with 508 additions and 368 deletions

View File

@@ -106,43 +106,25 @@ namespace SabreTools.DatTools
// Bucket and dedupe according to the flag
if (DedupeRoms == DedupeType.Full)
{
datFile.Items.BucketBy(ItemKey.CRC, DedupeRoms);
datFile.ItemsDB.BucketBy(ItemKey.CRC, DedupeRoms);
}
datFile.BucketBy(ItemKey.CRC, DedupeRoms);
else if (DedupeRoms == DedupeType.Game)
{
datFile.Items.BucketBy(ItemKey.Machine, DedupeRoms);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeRoms);
}
datFile.BucketBy(ItemKey.Machine, DedupeRoms);
// Process description to machine name
if (DescriptionAsName == true)
{
datFile.Items.MachineDescriptionToName(throwOnError);
datFile.ItemsDB.MachineDescriptionToName(throwOnError);
}
datFile.MachineDescriptionToName(throwOnError);
// If we are removing scene dates, do that now
if (SceneDateStrip == true)
{
datFile.Items.StripSceneDatesFromItems();
datFile.ItemsDB.StripSceneDatesFromItems();
}
datFile.StripSceneDatesFromItems();
// Run the one rom per game logic, if required
if (OneGamePerRegion == true && RegionList != null)
{
datFile.Items.SetOneGamePerRegion(RegionList);
datFile.ItemsDB.SetOneGamePerRegion(RegionList);
}
datFile.SetOneGamePerRegion(RegionList);
// Run the one rom per game logic, if required
if (OneRomPerGame == true)
{
datFile.Items.SetOneRomPerGame();
datFile.ItemsDB.SetOneRomPerGame();
}
datFile.SetOneRomPerGame();
// Remove all marked items
datFile.ClearMarked();
@@ -174,7 +156,7 @@ namespace SabreTools.DatTools
foreach (string key in keys)
{
// For every item in the current key
var items = datFile.Items[key];
var items = datFile.GetItemsForBucket(key);
if (items == null)
continue;
@@ -203,7 +185,7 @@ namespace SabreTools.DatTools
foreach (string key in keys)
{
// For every item in the current key
var items = datFile.ItemsDB.GetItemsForBucket(key);
var items = datFile.GetItemsForBucketDB(key);
if (items == null)
continue;

View File

@@ -95,7 +95,7 @@ namespace SabreTools.DatTools
try
{
// Bucket by game first
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None);
datFile.BucketBy(ItemKey.Machine, DedupeType.None);
// Create mappings based on the extra items
var combinedMaps = CombineExtras();
@@ -109,7 +109,7 @@ namespace SabreTools.DatTools
continue;
// Get the list of DatItems for the machine
var datItems = datFile.Items[machine];
var datItems = datFile.GetItemsForBucket(machine);
if (datItems == null)
continue;
@@ -158,7 +158,7 @@ namespace SabreTools.DatTools
try
{
// Bucket by game first
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None);
datFile.BucketBy(ItemKey.Machine, DedupeType.None);
// Create mappings based on the extra items
var combinedMaps = CombineExtras();
@@ -168,7 +168,7 @@ namespace SabreTools.DatTools
foreach (string game in games)
{
// Get the list of DatItems for the machine
var datItems = datFile.ItemsDB.GetItemsForBucket(game);
var datItems = datFile.GetItemsForBucketDB(game);
if (datItems == null)
continue;

View File

@@ -102,18 +102,14 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating device non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
while (datFile.Items.AddRomsFromDevices(false, false)) ;
while (datFile.ItemsDB.AddRomsFromDevices(false, false)) ;
while (datFile.Items.AddRomsFromDevices(true, false)) ;
while (datFile.ItemsDB.AddRomsFromDevices(true, false)) ;
while (datFile.AddRomsFromDevices(false, false)) ;
while (datFile.AddRomsFromDevices(true, false)) ;
// Then, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
/// <summary>
@@ -125,22 +121,17 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating fully merged sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
datFile.Items.AddRomsFromChildren(true, false);
datFile.ItemsDB.AddRomsFromChildren(true, false);
datFile.AddRomsFromChildren(true, false);
// Now that we have looped through the cloneof tags, we loop through the romof tags
datFile.Items.RemoveBiosRomsFromChild(false);
datFile.ItemsDB.RemoveBiosRomsFromChild(false);
datFile.Items.RemoveBiosRomsFromChild(true);
datFile.ItemsDB.RemoveBiosRomsFromChild(true);
datFile.RemoveBiosRomsFromChild(false);
datFile.RemoveBiosRomsFromChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
/// <summary>
@@ -152,24 +143,18 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating fully non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
while (datFile.Items.AddRomsFromDevices(true, true)) ;
while (datFile.ItemsDB.AddRomsFromDevices(true, true)) ;
datFile.Items.AddRomsFromDevices(false, true);
datFile.ItemsDB.AddRomsFromDevices(false, true);
datFile.Items.AddRomsFromParent();
datFile.ItemsDB.AddRomsFromParent();
while (datFile.AddRomsFromDevices(true, true)) ;
datFile.AddRomsFromDevices(false, true);
datFile.AddRomsFromParent();
// Now that we have looped through the cloneof tags, we loop through the romof tags
datFile.Items.AddRomsFromBios();
datFile.ItemsDB.AddRomsFromBios();
datFile.AddRomsFromBios();
// Then, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
/// <summary>
@@ -181,22 +166,17 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating merged sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
datFile.Items.AddRomsFromChildren(true, true);
datFile.ItemsDB.AddRomsFromChildren(true, true);
datFile.AddRomsFromChildren(true, true);
// Now that we have looped through the cloneof tags, we loop through the romof tags
datFile.Items.RemoveBiosRomsFromChild(false);
datFile.ItemsDB.RemoveBiosRomsFromChild(false);
datFile.Items.RemoveBiosRomsFromChild(true);
datFile.ItemsDB.RemoveBiosRomsFromChild(true);
datFile.RemoveBiosRomsFromChild(false);
datFile.RemoveBiosRomsFromChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
/// <summary>
@@ -208,22 +188,17 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
datFile.Items.AddRomsFromParent();
datFile.ItemsDB.AddRomsFromParent();
datFile.AddRomsFromParent();
// Now that we have looped through the cloneof tags, we loop through the romof tags
datFile.Items.RemoveBiosRomsFromChild(false);
datFile.ItemsDB.RemoveBiosRomsFromChild(false);
datFile.Items.RemoveBiosRomsFromChild(true);
datFile.ItemsDB.RemoveBiosRomsFromChild(true);
datFile.RemoveBiosRomsFromChild(false);
datFile.RemoveBiosRomsFromChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
/// <summary>
@@ -235,22 +210,17 @@ namespace SabreTools.DatTools
_staticLogger.User("Creating split sets from the DAT");
// For sake of ease, the first thing we want to do is bucket by game
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
// Now we want to loop through all of the games and set the correct information
datFile.Items.RemoveRomsFromChild();
datFile.ItemsDB.RemoveRomsFromChild();
datFile.RemoveRomsFromChild();
// Now that we have looped through the cloneof tags, we loop through the romof tags
datFile.Items.RemoveBiosRomsFromChild(false);
datFile.ItemsDB.RemoveBiosRomsFromChild(false);
datFile.Items.RemoveBiosRomsFromChild(true);
datFile.ItemsDB.RemoveBiosRomsFromChild(true);
datFile.RemoveBiosRomsFromChild(false);
datFile.RemoveBiosRomsFromChild(true);
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
datFile.Items.RemoveTagsFromChild();
datFile.ItemsDB.RemoveTagsFromChild();
datFile.RemoveTagsFromChild();
}
#endregion

View File

@@ -53,7 +53,7 @@ namespace SabreTools.DatTools
#region Perform setup
// If the DAT is not populated and inverse is not set, inform the user and quit
if (datFile.Items.DatStatistics.TotalCount == 0 && !inverse)
if (datFile.DatStatistics.TotalCount == 0 && !inverse)
{
_staticLogger.User("No entries were found to rebuild, exiting...");
return false;
@@ -106,7 +106,7 @@ namespace SabreTools.DatTools
return success;
// Now that we have a list of depots, we want to bucket the input DAT by SHA-1
datFile.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// Then we want to loop through each of the hashes and see if we can rebuild
List<string> keys = [.. datFile.Items.SortedKeys];
@@ -147,10 +147,10 @@ namespace SabreTools.DatTools
continue;
// Ensure we are sorted correctly (some other calls can change this)
//datFile.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
//datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// If there are no items in the hash, we continue
var items = datFile.Items[hash];
var items = datFile.GetItemsForBucket(hash);
if (items == null || items.Count == 0)
continue;
@@ -204,7 +204,7 @@ namespace SabreTools.DatTools
#region Perform setup
// If the DAT is not populated and inverse is not set, inform the user and quit
if (datFile.Items.DatStatistics.TotalCount == 0 && !inverse)
if (datFile.DatStatistics.TotalCount == 0 && !inverse)
{
_staticLogger.User("No entries were found to rebuild, exiting...");
return false;
@@ -451,7 +451,7 @@ namespace SabreTools.DatTools
if (outputFormat == OutputFormat.Folder && datFile.Header.GetStringFieldValue(Models.Metadata.Header.ForcePackingKey).AsEnumValue<PackingFlag>() == PackingFlag.Partial)
{
shouldCheck = true;
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, lower: false);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, lower: false);
}
// Now loop through the list and rebuild accordingly
@@ -463,7 +463,7 @@ namespace SabreTools.DatTools
continue;
// If we should check for the items in the machine
var items = datFile.Items[machine.GetStringFieldValue(Models.Metadata.Machine.NameKey)!];
var items = datFile.GetItemsForBucket(machine.GetStringFieldValue(Models.Metadata.Machine.NameKey)!);
if (shouldCheck && items!.Count > 1)
outputFormat = OutputFormat.Folder;
else if (shouldCheck && items!.Count == 1)
@@ -553,7 +553,7 @@ namespace SabreTools.DatTools
private static bool ShouldRebuild(DatFile datFile, DatItem datItem, Stream? stream, bool inverse, out List<DatItem> dupes)
{
// Find if the file has duplicates in the DAT
dupes = datFile.Items.GetDuplicates(datItem);
dupes = datFile.GetDuplicates(datItem);
bool hasDuplicates = dupes.Count > 0;
// If we have duplicates but we're filtering
@@ -609,7 +609,7 @@ namespace SabreTools.DatTools
private static bool ShouldRebuildDB(DatFile datFile, KeyValuePair<long, DatItem> datItem, Stream? stream, bool inverse, out Dictionary<long, DatItem> dupes)
{
// Find if the file has duplicates in the DAT
dupes = datFile.ItemsDB.GetDuplicates(datItem);
dupes = datFile.GetDuplicatesDB(datItem);
bool hasDuplicates = dupes.Count > 0;
// If we have duplicates but we're filtering

View File

@@ -41,7 +41,7 @@ namespace SabreTools.DatTools
public static (DatFile? extADat, DatFile? extBDat) SplitByExtension(DatFile datFile, List<string> extA, List<string> extB)
{
// If roms is empty, return false
if (datFile.Items.DatStatistics.TotalCount == 0)
if (datFile.DatStatistics.TotalCount == 0)
return (null, null);
InternalStopwatch watch = new($"Splitting DAT by extension");
@@ -73,7 +73,7 @@ namespace SabreTools.DatTools
foreach (var key in datFile.Items.Keys)
#endif
{
var items = datFile.Items[key];
var items = datFile.GetItemsForBucket(key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP
return;
@@ -249,7 +249,7 @@ namespace SabreTools.DatTools
foreach (var key in datFile.Items.Keys)
#endif
{
var items = datFile.Items[key];
var items = datFile.GetItemsForBucket(key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP
return;
@@ -493,7 +493,7 @@ namespace SabreTools.DatTools
InternalStopwatch watch = new($"Splitting DAT by level");
// First, bucket by games so that we can do the right thing
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, lower: false, norename: true);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, lower: false, norename: true);
// Create a temporary DAT to add things to
DatFile tempDat = DatFileTool.CreateDatFile(datFile.Header);
@@ -521,7 +521,7 @@ namespace SabreTools.DatTools
}
// Clean the input list and set all games to be pathless
List<DatItem>? items = datFile.Items[key];
List<DatItem>? items = datFile.GetItemsForBucket(key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP
return;
@@ -638,7 +638,7 @@ namespace SabreTools.DatTools
foreach (var key in datFile.Items.Keys)
#endif
{
List<DatItem>? items = datFile.Items[key];
List<DatItem>? items = datFile.GetItemsForBucket(key);
if (items == null)
#if NET40_OR_GREATER || NETCOREAPP
return;
@@ -777,7 +777,7 @@ namespace SabreTools.DatTools
InternalStopwatch watch = new($"Splitting DAT by total size");
// Sort the DatFile by machine name
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None);
datFile.BucketBy(ItemKey.Machine, DedupeType.None);
// Get the keys in a known order for easier sorting
var keys = datFile.Items.SortedKeys;
@@ -920,7 +920,7 @@ namespace SabreTools.DatTools
foreach (var key in datFile.Items.Keys)
#endif
{
List<DatItem> items = DatFileTool.Merge(datFile.Items[key]);
List<DatItem> items = DatFileTool.Merge(datFile.GetItemsForBucket(key));
// If the rom list is empty or null, just skip it
if (items == null || items.Count == 0)

View File

@@ -81,21 +81,18 @@ namespace SabreTools.DatTools
// Add single DAT stats (if asked)
if (single)
{
DatStatistics individualStats = datdata.Items.DatStatistics;
//DatStatistics individualStats = datdata.ItemsDB.DatStatistics;
DatStatistics individualStats = datdata.DatStatistics;
individualStats.DisplayName = datdata.Header.GetStringFieldValue(DatHeader.FileNameKey);
individualStats.MachineCount = datdata.Items.Keys.Count;
stats.Add(individualStats);
}
// Add single DAT stats to dir
dirStats.AddStatistics(datdata.Items.DatStatistics);
//dirStats.AddStatistics(datdata.ItemsDB.DatStatistics);
dirStats.AddStatistics(datdata.DatStatistics);
dirStats.GameCount += datdata.Items.Keys.Count;
// Add single DAT stats to totals
totalStats.AddStatistics(datdata.Items.DatStatistics);
//totalStats.AddStatistics(datdata.ItemsDB.DatStatistics);
totalStats.AddStatistics(datdata.DatStatistics);
totalStats.GameCount += datdata.Items.Keys.Count;
// Make sure to assign the new directory

View File

@@ -55,7 +55,7 @@ namespace SabreTools.DatTools
return success;
// Now that we have a list of depots, we want to bucket the input DAT by SHA-1
datFile.Items.BucketBy(ItemKey.SHA1, DedupeType.None);
datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// Then we want to loop through each of the hashes and see if we can rebuild
List<string> keys = [.. datFile.Items.SortedKeys];
@@ -96,8 +96,8 @@ namespace SabreTools.DatTools
continue;
// Now we want to remove all duplicates from the DAT
datFile.Items.GetDuplicates(fileinfo.ConvertToRom())
.AddRange(datFile.Items.GetDuplicates(fileinfo.ConvertToDisk()));
datFile.GetDuplicates(fileinfo.ConvertToRom())
.AddRange(datFile.GetDuplicates(fileinfo.ConvertToDisk()));
}
watch.Stop();
@@ -140,7 +140,7 @@ namespace SabreTools.DatTools
return success;
// Now that we have a list of depots, we want to bucket the input DAT by SHA-1
datFile.ItemsDB.BucketBy(ItemKey.SHA1, DedupeType.None);
datFile.BucketBy(ItemKey.SHA1, DedupeType.None);
// Then we want to loop through each of the hashes and see if we can rebuild
List<string> keys = [.. datFile.ItemsDB.SortedKeys];
@@ -181,8 +181,8 @@ namespace SabreTools.DatTools
continue;
// Now we want to remove all duplicates from the DAT
datFile.ItemsDB.GetDuplicates(new KeyValuePair<long, DatItem>(-1, fileinfo.ConvertToRom()))
.Concat(datFile.ItemsDB.GetDuplicates(new KeyValuePair<long, DatItem>(-1, fileinfo.ConvertToDisk())));
datFile.GetDuplicatesDB(new KeyValuePair<long, DatItem>(-1, fileinfo.ConvertToRom()))
.Concat(datFile.GetDuplicatesDB(new KeyValuePair<long, DatItem>(-1, fileinfo.ConvertToDisk())));
}
watch.Stop();
@@ -211,15 +211,15 @@ namespace SabreTools.DatTools
// Force bucketing according to the flags
datFile.Items.SetBucketedBy(ItemKey.NULL);
if (hashOnly)
datFile.Items.BucketBy(ItemKey.CRC, DedupeType.Full);
datFile.BucketBy(ItemKey.CRC, DedupeType.Full);
else
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.Full);
datFile.BucketBy(ItemKey.Machine, DedupeType.Full);
// Then mark items for removal
List<string> keys = [.. datFile.Items.SortedKeys];
foreach (string key in keys)
{
List<DatItem>? items = datFile.Items[key];
List<DatItem>? items = datFile.GetItemsForBucket(key);
if (items == null)
continue;
@@ -259,9 +259,9 @@ namespace SabreTools.DatTools
// Force bucketing according to the flags
if (hashOnly)
datFile.ItemsDB.BucketBy(ItemKey.CRC, DedupeType.Full);
datFile.BucketBy(ItemKey.CRC, DedupeType.Full);
else
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.Full);
datFile.BucketBy(ItemKey.Machine, DedupeType.Full);
// Then mark items for removal
List<string> keys = [.. datFile.ItemsDB.SortedKeys];

View File

@@ -77,12 +77,10 @@ namespace SabreTools.DatTools
EnsureHeaderFields(datFile);
// Bucket roms by game name, if not already
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None);
datFile.BucketBy(ItemKey.Machine, DedupeType.None);
// Output the number of items we're going to be writing
_staticLogger.User($"A total of {datFile.Items.DatStatistics.TotalCount - datFile.Items.DatStatistics.RemovedCount} items will be written out to '{datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)}'");
//logger.User($"A total of {datFile.ItemsDB.DatStatistics.TotalCount - datFile.ItemsDB.DatStatistics.RemovedCount} items will be written out to '{datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)}'");
_staticLogger.User($"A total of {datFile.DatStatistics.TotalCount - datFile.DatStatistics.RemovedCount} items will be written out to '{datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)}'");
// Get the outfile names
Dictionary<DatFormat, string> outfiles = datFile.Header.CreateOutFileNames(outDir!, overwrite);
@@ -133,33 +131,21 @@ namespace SabreTools.DatTools
/// <param name="datFile">Current DatFile object to write from</param>
public static void WriteStatsToConsole(DatFile datFile)
{
long diskCount = datFile.Items.DatStatistics.GetItemCount(ItemType.Disk);
long mediaCount = datFile.Items.DatStatistics.GetItemCount(ItemType.Media);
long romCount = datFile.Items.DatStatistics.GetItemCount(ItemType.Rom);
long diskCount = datFile.DatStatistics.GetItemCount(ItemType.Disk);
long mediaCount = datFile.DatStatistics.GetItemCount(ItemType.Media);
long romCount = datFile.DatStatistics.GetItemCount(ItemType.Rom);
if (diskCount + mediaCount + romCount == 0)
datFile.Items.RecalculateStats();
diskCount = datFile.ItemsDB.DatStatistics.GetItemCount(ItemType.Disk);
mediaCount = datFile.ItemsDB.DatStatistics.GetItemCount(ItemType.Media);
romCount = datFile.ItemsDB.DatStatistics.GetItemCount(ItemType.Rom);
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
if (diskCount + mediaCount + romCount == 0)
datFile.ItemsDB.RecalculateStats();
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.ItemsDB.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
datFile.Items.DatStatistics.DisplayName = datFile.Header.GetStringFieldValue(DatHeader.FileNameKey);
datFile.Items.DatStatistics.MachineCount = datFile.Items.Keys.Count;
datFile.ItemsDB.DatStatistics.DisplayName = datFile.Header.GetStringFieldValue(DatHeader.FileNameKey);
datFile.ItemsDB.DatStatistics.MachineCount = datFile.Items.Keys.Count;
datFile.DatStatistics.DisplayName = datFile.Header.GetStringFieldValue(DatHeader.FileNameKey);
datFile.DatStatistics.MachineCount = datFile.Items.Keys.Count;
List<DatStatistics> statsList =
[
datFile.Items.DatStatistics,
//datFile.ItemsDB.DatStatistics,
datFile.DatStatistics,
];
var consoleOutput = BaseReport.Create(StatReportFormat.None, statsList);
consoleOutput!.WriteToFile(null, true, true);
@@ -232,13 +218,13 @@ namespace SabreTools.DatTools
datFile.ItemsDB.RecalculateStats();
// If there's nothing there, abort
if (datFile.Items.DatStatistics.TotalCount == 0)
if (datFile.DatStatistics.TotalCount == 0)
return false;
// if (datFile.ItemsDB.DatStatistics.TotalCount == 0)
// return false;
// If every item is removed, abort
if (datFile.Items.DatStatistics.TotalCount == datFile.Items.DatStatistics.RemovedCount)
if (datFile.DatStatistics.TotalCount == datFile.DatStatistics.RemovedCount)
return false;
// if (datFile.ItemsDB.DatStatistics.TotalCount == datFile.ItemsDB.DatStatistics.RemovedCount)
// return false;