Make statistics a bit less strange

This commit is contained in:
Matt Nadareski
2024-10-24 01:51:04 -04:00
parent d8988b5932
commit be2fc9ae7c
2 changed files with 29 additions and 19 deletions

View File

@@ -66,12 +66,36 @@ namespace SabreTools.DatFiles
/// <summary>
/// Total machine count to use on output
/// </summary>
public long MachineCount { get; set; } = 0;
public long MachineCount { get; set; }
/// <summary>
/// Determines if statistics are for a directory or not
/// </summary>
public bool IsDirectory { get; set; } = false;
public readonly bool IsDirectory;
#endregion
#region Constructors
/// <summary>
/// Default constructor
/// </summary>
public DatStatistics()
{
DisplayName = null;
MachineCount = 0;
IsDirectory = false;
}
/// <summary>
/// Constructor for aggregate data
/// </summary>
public DatStatistics(string? displayName, bool isDirectory)
{
DisplayName = displayName;
MachineCount = 0;
IsDirectory = isDirectory;
}
#endregion

View File

@@ -48,20 +48,11 @@ namespace SabreTools.DatTools
.ToList();
// Init total
DatStatistics totalStats = new()
{
DisplayName = "DIR: All DATs",
MachineCount = 0,
IsDirectory = true,
};
DatStatistics totalStats = new("DIR: All DATs", isDirectory: true);
// Init directory-level variables
string? lastdir = null;
DatStatistics dirStats = new()
{
MachineCount = 0,
IsDirectory = true,
};
DatStatistics dirStats = new(displayName: null, isDirectory: true);
// Now process each of the input files
foreach (ParentablePath file in files)
@@ -79,11 +70,7 @@ namespace SabreTools.DatTools
#endif
dirStats.MachineCount = dirStats.GameCount;
stats.Add(dirStats);
dirStats = new DatStatistics
{
MachineCount = 0,
IsDirectory = true,
};
dirStats = new DatStatistics(displayName: null, isDirectory: true);
}
InternalStopwatch watch = new($"Collecting statistics for '{file.CurrentPath}'");
@@ -98,7 +85,6 @@ namespace SabreTools.DatTools
//DatStatistics individualStats = datdata.ItemsDB.DatStatistics;
individualStats.DisplayName = datdata.Header.GetStringFieldValue(DatHeader.FileNameKey);
individualStats.MachineCount = datdata.Items.Keys.Count;
individualStats.IsDirectory = false;
stats.Add(individualStats);
}