mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Statistics overhaul
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
|
||||||
@@ -48,6 +48,8 @@ namespace SabreTools.Library.Dats
|
|||||||
private bool _romba;
|
private bool _romba;
|
||||||
|
|
||||||
// Statistical data related to the DAT
|
// Statistical data related to the DAT
|
||||||
|
private object _statslock = new object();
|
||||||
|
private long _count;
|
||||||
private long _romCount;
|
private long _romCount;
|
||||||
private long _diskCount;
|
private long _diskCount;
|
||||||
private long _totalSize;
|
private long _totalSize;
|
||||||
@@ -183,7 +185,6 @@ namespace SabreTools.Library.Dats
|
|||||||
public SortedBy SortedBy
|
public SortedBy SortedBy
|
||||||
{
|
{
|
||||||
get { return _sortedBy; }
|
get { return _sortedBy; }
|
||||||
set { _sortedBy = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Data specific to the Miss DAT type
|
// Data specific to the Miss DAT type
|
||||||
@@ -234,60 +235,53 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Statistical data related to the DAT
|
// Statistical data related to the DAT
|
||||||
|
public long Count
|
||||||
|
{
|
||||||
|
get { return _count; }
|
||||||
|
}
|
||||||
public long RomCount
|
public long RomCount
|
||||||
{
|
{
|
||||||
get { return _romCount; }
|
get { return _romCount; }
|
||||||
set { _romCount = value; }
|
|
||||||
}
|
}
|
||||||
public long DiskCount
|
public long DiskCount
|
||||||
{
|
{
|
||||||
get { return _diskCount; }
|
get { return _diskCount; }
|
||||||
set { _diskCount = value; }
|
|
||||||
}
|
}
|
||||||
public long TotalSize
|
public long TotalSize
|
||||||
{
|
{
|
||||||
get { return _totalSize; }
|
get { return _totalSize; }
|
||||||
set { _totalSize = value; }
|
|
||||||
}
|
}
|
||||||
public long CRCCount
|
public long CRCCount
|
||||||
{
|
{
|
||||||
get { return _crcCount; }
|
get { return _crcCount; }
|
||||||
set { _crcCount = value; }
|
|
||||||
}
|
}
|
||||||
public long MD5Count
|
public long MD5Count
|
||||||
{
|
{
|
||||||
get { return _md5Count; }
|
get { return _md5Count; }
|
||||||
set { _md5Count = value; }
|
|
||||||
}
|
}
|
||||||
public long SHA1Count
|
public long SHA1Count
|
||||||
{
|
{
|
||||||
get { return _sha1Count; }
|
get { return _sha1Count; }
|
||||||
set { _sha1Count = value; }
|
|
||||||
}
|
}
|
||||||
public long SHA256Count
|
public long SHA256Count
|
||||||
{
|
{
|
||||||
get { return _sha256Count; }
|
get { return _sha256Count; }
|
||||||
set { _sha256Count = value; }
|
|
||||||
}
|
}
|
||||||
public long SHA384Count
|
public long SHA384Count
|
||||||
{
|
{
|
||||||
get { return _sha384Count; }
|
get { return _sha384Count; }
|
||||||
set { _sha384Count = value; }
|
|
||||||
}
|
}
|
||||||
public long SHA512Count
|
public long SHA512Count
|
||||||
{
|
{
|
||||||
get { return _sha512Count; }
|
get { return _sha512Count; }
|
||||||
set { _sha512Count = value; }
|
|
||||||
}
|
}
|
||||||
public long BaddumpCount
|
public long BaddumpCount
|
||||||
{
|
{
|
||||||
get { return _baddumpCount; }
|
get { return _baddumpCount; }
|
||||||
set { _baddumpCount = value; }
|
|
||||||
}
|
}
|
||||||
public long NodumpCount
|
public long NodumpCount
|
||||||
{
|
{
|
||||||
get { return _nodumpCount; }
|
get { return _nodumpCount; }
|
||||||
set { _nodumpCount = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -347,7 +341,7 @@ namespace SabreTools.Library.Dats
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a new key to the file dictionary
|
/// Add a new key to the file dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key">Key in the dictionary to add to</param>
|
/// <param name="key">Key in the dictionary to add</param>
|
||||||
public void Add(string key)
|
public void Add(string key)
|
||||||
{
|
{
|
||||||
// If the dictionary is null, create it
|
// If the dictionary is null, create it
|
||||||
@@ -379,16 +373,16 @@ namespace SabreTools.Library.Dats
|
|||||||
_files = new SortedDictionary<string, List<DatItem>>();
|
_files = new SortedDictionary<string, List<DatItem>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the key, if necessary
|
||||||
|
Add(key);
|
||||||
|
|
||||||
lock (_files)
|
lock (_files)
|
||||||
{
|
{
|
||||||
// If the key is missing from the dictionary, add it
|
|
||||||
if (!_files.ContainsKey(key))
|
|
||||||
{
|
|
||||||
_files.Add(key, new List<DatItem>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now add the value
|
// Now add the value
|
||||||
_files[key].Add(value);
|
_files[key].Add(value);
|
||||||
|
|
||||||
|
// Now update the statistics
|
||||||
|
AddItemStatistics(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,16 +399,19 @@ namespace SabreTools.Library.Dats
|
|||||||
_files = new SortedDictionary<string, List<DatItem>>();
|
_files = new SortedDictionary<string, List<DatItem>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the key, if necessary
|
||||||
|
Add(key);
|
||||||
|
|
||||||
lock (_files)
|
lock (_files)
|
||||||
{
|
{
|
||||||
// If the key is missing from the dictionary, add it
|
|
||||||
if (!_files.ContainsKey(key))
|
|
||||||
{
|
|
||||||
_files.Add(key, new List<DatItem>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now add the value
|
// Now add the value
|
||||||
_files[key].AddRange(value);
|
_files[key].AddRange(value);
|
||||||
|
|
||||||
|
// Now update the statistics
|
||||||
|
foreach (DatItem item in value)
|
||||||
|
{
|
||||||
|
AddItemStatistics(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,39 +440,15 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Get the number of DatItems in the file dictionary
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>Number of DatItems in the file dictionary</returns>
|
|
||||||
public long Count
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// If the dictionary is null, create it
|
|
||||||
if (_files == null)
|
|
||||||
{
|
|
||||||
_files = new SortedDictionary<string, List<DatItem>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_files)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
foreach (string key in _files.Keys)
|
|
||||||
{
|
|
||||||
count += _files[key].Count;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete the file dictionary
|
/// Delete the file dictionary
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Delete()
|
public void Delete()
|
||||||
{
|
{
|
||||||
_files = null;
|
_files = null;
|
||||||
|
|
||||||
|
// Reset statistics
|
||||||
|
ResetStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -516,6 +489,12 @@ namespace SabreTools.Library.Dats
|
|||||||
// If the key is in the dictionary, remove it
|
// If the key is in the dictionary, remove it
|
||||||
if (_files.ContainsKey(key))
|
if (_files.ContainsKey(key))
|
||||||
{
|
{
|
||||||
|
// Remove the statistics first
|
||||||
|
foreach (DatItem item in _files[key])
|
||||||
|
{
|
||||||
|
RemoveItemStatistics(item);
|
||||||
|
}
|
||||||
|
|
||||||
_files.Remove(key);
|
_files.Remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -527,15 +506,9 @@ namespace SabreTools.Library.Dats
|
|||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
_files = new SortedDictionary<string, List<DatItem>>();
|
_files = new SortedDictionary<string, List<DatItem>>();
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
// Reset statistics
|
||||||
/// Set a new file dictionary from an existing one
|
ResetStatistics();
|
||||||
/// </summary>
|
|
||||||
/// <param name="newdict"></param>
|
|
||||||
public void Set(SortedDictionary<string, List<DatItem>> newdict)
|
|
||||||
{
|
|
||||||
_files = newdict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace SabreTools.Library.Dats
|
|||||||
Globals.ParallelOptions,
|
Globals.ParallelOptions,
|
||||||
path =>
|
path =>
|
||||||
{
|
{
|
||||||
Globals.Logger.User("Comparing '" + path + "' to base DAT");
|
Globals.Logger.User("Comparing '" + path.Split('¬')[0] + "' to base DAT");
|
||||||
|
|
||||||
// First we parse in the DAT internally
|
// First we parse in the DAT internally
|
||||||
DatFile intDat = new DatFile();
|
DatFile intDat = new DatFile();
|
||||||
|
|||||||
@@ -3121,38 +3121,9 @@ namespace SabreTools.Library.Dats
|
|||||||
break;
|
break;
|
||||||
case ItemType.Disk:
|
case ItemType.Disk:
|
||||||
key = ((Disk)item).MD5;
|
key = ((Disk)item).MD5;
|
||||||
|
|
||||||
// Add statistical data
|
|
||||||
DiskCount += 1;
|
|
||||||
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
|
|
||||||
{
|
|
||||||
TotalSize += 0;
|
|
||||||
MD5Count += (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1);
|
|
||||||
SHA1Count += (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1);
|
|
||||||
SHA256Count += (String.IsNullOrEmpty(((Disk)item).SHA256) ? 0 : 1);
|
|
||||||
SHA384Count += (String.IsNullOrEmpty(((Disk)item).SHA384) ? 0 : 1);
|
|
||||||
SHA512Count += (String.IsNullOrEmpty(((Disk)item).SHA512) ? 0 : 1);
|
|
||||||
}
|
|
||||||
BaddumpCount += (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
|
||||||
NodumpCount += (((Disk)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
|
||||||
break;
|
break;
|
||||||
case ItemType.Rom:
|
case ItemType.Rom:
|
||||||
key = ((Rom)item).Size + "-" + ((Rom)item).CRC;
|
key = ((Rom)item).Size + "-" + ((Rom)item).CRC;
|
||||||
|
|
||||||
// Add statistical data
|
|
||||||
RomCount += 1;
|
|
||||||
if (((Rom)item).ItemStatus != ItemStatus.Nodump)
|
|
||||||
{
|
|
||||||
TotalSize += ((Rom)item).Size;
|
|
||||||
CRCCount += (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1);
|
|
||||||
MD5Count += (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1);
|
|
||||||
SHA1Count += (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1);
|
|
||||||
SHA256Count += (String.IsNullOrEmpty(((Rom)item).SHA256) ? 0 : 1);
|
|
||||||
SHA384Count += (String.IsNullOrEmpty(((Rom)item).SHA384) ? 0 : 1);
|
|
||||||
SHA512Count += (String.IsNullOrEmpty(((Rom)item).SHA512) ? 0 : 1);
|
|
||||||
}
|
|
||||||
BaddumpCount += (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
|
||||||
NodumpCount += (((Rom)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
key = "default";
|
key = "default";
|
||||||
|
|||||||
@@ -28,21 +28,146 @@ namespace SabreTools.Library.Dats
|
|||||||
|
|
||||||
#region Statistics
|
#region Statistics
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add to the internal statistics given a DatItem
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">Item to add info from</param>
|
||||||
|
private void AddItemStatistics(DatItem item)
|
||||||
|
{
|
||||||
|
// No matter what the item is, we increate the count
|
||||||
|
lock (_statslock)
|
||||||
|
{
|
||||||
|
_count += 1;
|
||||||
|
|
||||||
|
// Now we do different things for each item type
|
||||||
|
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.Archive:
|
||||||
|
break;
|
||||||
|
case ItemType.BiosSet:
|
||||||
|
break;
|
||||||
|
case ItemType.Disk:
|
||||||
|
_diskCount += 1;
|
||||||
|
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
|
||||||
|
{
|
||||||
|
_md5Count += (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1);
|
||||||
|
_sha1Count += (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1);
|
||||||
|
_sha256Count += (String.IsNullOrEmpty(((Disk)item).SHA256) ? 0 : 1);
|
||||||
|
_sha384Count += (String.IsNullOrEmpty(((Disk)item).SHA384) ? 0 : 1);
|
||||||
|
_sha512Count += (String.IsNullOrEmpty(((Disk)item).SHA512) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baddumpCount += (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
|
_nodumpCount += (((Disk)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case ItemType.Release:
|
||||||
|
break;
|
||||||
|
case ItemType.Rom:
|
||||||
|
_romCount += 1;
|
||||||
|
if (((Rom)item).ItemStatus != ItemStatus.Nodump)
|
||||||
|
{
|
||||||
|
_totalSize += ((Rom)item).Size;
|
||||||
|
_crcCount += (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1);
|
||||||
|
_md5Count += (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1);
|
||||||
|
_sha1Count += (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1);
|
||||||
|
_sha256Count += (String.IsNullOrEmpty(((Rom)item).SHA256) ? 0 : 1);
|
||||||
|
_sha384Count += (String.IsNullOrEmpty(((Rom)item).SHA384) ? 0 : 1);
|
||||||
|
_sha512Count += (String.IsNullOrEmpty(((Rom)item).SHA512) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baddumpCount += (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
|
_nodumpCount += (((Rom)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case ItemType.Sample:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove from the internal statistics given a DatItem
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">Item to remove info for</param>
|
||||||
|
private void RemoveItemStatistics(DatItem item)
|
||||||
|
{
|
||||||
|
// No matter what the item is, we increate the count
|
||||||
|
lock (_statslock)
|
||||||
|
{
|
||||||
|
_count -= 1;
|
||||||
|
|
||||||
|
// Now we do different things for each item type
|
||||||
|
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.Archive:
|
||||||
|
break;
|
||||||
|
case ItemType.BiosSet:
|
||||||
|
break;
|
||||||
|
case ItemType.Disk:
|
||||||
|
_diskCount -= 1;
|
||||||
|
if (((Disk)item).ItemStatus != ItemStatus.Nodump)
|
||||||
|
{
|
||||||
|
_md5Count -= (String.IsNullOrEmpty(((Disk)item).MD5) ? 0 : 1);
|
||||||
|
_sha1Count -= (String.IsNullOrEmpty(((Disk)item).SHA1) ? 0 : 1);
|
||||||
|
_sha256Count -= (String.IsNullOrEmpty(((Disk)item).SHA256) ? 0 : 1);
|
||||||
|
_sha384Count -= (String.IsNullOrEmpty(((Disk)item).SHA384) ? 0 : 1);
|
||||||
|
_sha512Count -= (String.IsNullOrEmpty(((Disk)item).SHA512) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baddumpCount -= (((Disk)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
|
_nodumpCount -= (((Disk)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case ItemType.Release:
|
||||||
|
break;
|
||||||
|
case ItemType.Rom:
|
||||||
|
_romCount -= 1;
|
||||||
|
if (((Rom)item).ItemStatus != ItemStatus.Nodump)
|
||||||
|
{
|
||||||
|
_totalSize -= ((Rom)item).Size;
|
||||||
|
_crcCount -= (String.IsNullOrEmpty(((Rom)item).CRC) ? 0 : 1);
|
||||||
|
_md5Count -= (String.IsNullOrEmpty(((Rom)item).MD5) ? 0 : 1);
|
||||||
|
_sha1Count -= (String.IsNullOrEmpty(((Rom)item).SHA1) ? 0 : 1);
|
||||||
|
_sha256Count -= (String.IsNullOrEmpty(((Rom)item).SHA256) ? 0 : 1);
|
||||||
|
_sha384Count -= (String.IsNullOrEmpty(((Rom)item).SHA384) ? 0 : 1);
|
||||||
|
_sha512Count -= (String.IsNullOrEmpty(((Rom)item).SHA512) ? 0 : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baddumpCount -= (((Rom)item).ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||||
|
_nodumpCount -= (((Rom)item).ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
||||||
|
break;
|
||||||
|
case ItemType.Sample:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset all statistics
|
||||||
|
/// </summary>
|
||||||
|
private void ResetStatistics()
|
||||||
|
{
|
||||||
|
_count = 0;
|
||||||
|
_romCount = 0;
|
||||||
|
_diskCount = 0;
|
||||||
|
_totalSize = 0;
|
||||||
|
_crcCount = 0;
|
||||||
|
_md5Count = 0;
|
||||||
|
_sha1Count = 0;
|
||||||
|
_sha256Count = 0;
|
||||||
|
_sha384Count = 0;
|
||||||
|
_sha512Count = 0;
|
||||||
|
_baddumpCount = 0;
|
||||||
|
_nodumpCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Recalculate the statistics for the Dat
|
/// Recalculate the statistics for the Dat
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void RecalculateStats()
|
public void RecalculateStats()
|
||||||
{
|
{
|
||||||
// Wipe out any stats already there
|
// Wipe out any stats already there
|
||||||
RomCount = 0;
|
ResetStatistics();
|
||||||
DiskCount = 0;
|
|
||||||
TotalSize = 0;
|
|
||||||
CRCCount = 0;
|
|
||||||
MD5Count = 0;
|
|
||||||
SHA1Count = 0;
|
|
||||||
SHA256Count = 0;
|
|
||||||
BaddumpCount = 0;
|
|
||||||
NodumpCount = 0;
|
|
||||||
|
|
||||||
// If we have a blank Dat in any way, return
|
// If we have a blank Dat in any way, return
|
||||||
if (this == null || Count == 0)
|
if (this == null || Count == 0)
|
||||||
@@ -57,41 +182,7 @@ namespace SabreTools.Library.Dats
|
|||||||
List<DatItem> items = this[key];
|
List<DatItem> items = this[key];
|
||||||
Parallel.ForEach(items, Globals.ParallelOptions, item =>
|
Parallel.ForEach(items, Globals.ParallelOptions, item =>
|
||||||
{
|
{
|
||||||
switch (item.Type)
|
AddItemStatistics(item);
|
||||||
{
|
|
||||||
case ItemType.Archive:
|
|
||||||
break;
|
|
||||||
case ItemType.BiosSet:
|
|
||||||
break;
|
|
||||||
case ItemType.Disk:
|
|
||||||
Disk disk = (Disk)item;
|
|
||||||
DiskCount += 1;
|
|
||||||
MD5Count += (String.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
|
||||||
SHA1Count += (String.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
|
||||||
SHA256Count += (String.IsNullOrEmpty(disk.SHA256) ? 0 : 1);
|
|
||||||
SHA384Count += (String.IsNullOrEmpty(disk.SHA384) ? 0 : 1);
|
|
||||||
SHA512Count += (String.IsNullOrEmpty(disk.SHA512) ? 0 : 1);
|
|
||||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
|
||||||
NodumpCount += (disk.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
|
||||||
break;
|
|
||||||
case ItemType.Release:
|
|
||||||
break;
|
|
||||||
case ItemType.Rom:
|
|
||||||
Rom rom = (Rom)item;
|
|
||||||
RomCount += 1;
|
|
||||||
TotalSize += (rom.ItemStatus == ItemStatus.Nodump ? 0 : rom.Size);
|
|
||||||
CRCCount += (String.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
|
||||||
MD5Count += (String.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
|
||||||
SHA1Count += (String.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
|
||||||
SHA256Count += (String.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
|
|
||||||
SHA384Count += (String.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
|
|
||||||
SHA512Count += (String.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
|
|
||||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
|
||||||
NodumpCount += (rom.ItemStatus == ItemStatus.Nodump ? 1 : 0);
|
|
||||||
break;
|
|
||||||
case ItemType.Sample:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -115,32 +206,32 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
|
|
||||||
BucketBy(SortedBy.Game, false /* mergeroms */, norename: true);
|
BucketBy(SortedBy.Game, false /* mergeroms */, norename: true);
|
||||||
if (TotalSize < 0)
|
if (_totalSize < 0)
|
||||||
{
|
{
|
||||||
TotalSize = Int64.MaxValue + TotalSize;
|
_totalSize = Int64.MaxValue + _totalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the results to screen
|
// Log the results to screen
|
||||||
string results = @"For '" + FileName + @"':
|
string results = @"For '" + _fileName + @"':
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @"
|
Uncompressed size: " + Style.GetBytesReadable(_totalSize) + @"
|
||||||
Games found: " + (game == -1 ? Keys.Count() : game) + @"
|
Games found: " + (game == -1 ? Keys.Count() : game) + @"
|
||||||
Roms found: " + RomCount + @"
|
Roms found: " + _romCount + @"
|
||||||
Disks found: " + DiskCount + @"
|
Disks found: " + _diskCount + @"
|
||||||
Roms with CRC: " + CRCCount + @"
|
Roms with CRC: " + _crcCount + @"
|
||||||
Roms with MD5: " + MD5Count + @"
|
Roms with MD5: " + _md5Count + @"
|
||||||
Roms with SHA-1: " + SHA1Count + @"
|
Roms with SHA-1: " + _sha1Count + @"
|
||||||
Roms with SHA-256: " + SHA256Count + @"
|
Roms with SHA-256: " + _sha256Count + @"
|
||||||
Roms with SHA-384: " + SHA384Count + @"
|
Roms with SHA-384: " + _sha384Count + @"
|
||||||
Roms with SHA-512: " + SHA512Count + "\n";
|
Roms with SHA-512: " + _sha512Count + "\n";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
{
|
{
|
||||||
results += " Roms with BadDump status: " + BaddumpCount + "\n";
|
results += " Roms with BadDump status: " + _baddumpCount + "\n";
|
||||||
}
|
}
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
{
|
{
|
||||||
results += " Roms with Nodump status: " + NodumpCount + "\n";
|
results += " Roms with Nodump status: " + _nodumpCount + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// For spacing between DATs
|
// For spacing between DATs
|
||||||
@@ -152,25 +243,25 @@ namespace SabreTools.Library.Dats
|
|||||||
string line = "";
|
string line = "";
|
||||||
if (outputs.ContainsKey(StatDatFormat.None))
|
if (outputs.ContainsKey(StatDatFormat.None))
|
||||||
{
|
{
|
||||||
line = @"'" + FileName + @"':
|
line = @"'" + _fileName + @"':
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
Uncompressed size: " + Style.GetBytesReadable(TotalSize) + @"
|
Uncompressed size: " + Style.GetBytesReadable(_totalSize) + @"
|
||||||
Games found: " + (game == -1 ? Keys.Count() : game) + @"
|
Games found: " + (game == -1 ? Keys.Count() : game) + @"
|
||||||
Roms found: " + RomCount + @"
|
Roms found: " + _romCount + @"
|
||||||
Disks found: " + DiskCount + @"
|
Disks found: " + _diskCount + @"
|
||||||
Roms with CRC: " + CRCCount + @"
|
Roms with CRC: " + _crcCount + @"
|
||||||
Roms with SHA-1: " + SHA1Count + @"
|
Roms with SHA-1: " + _sha1Count + @"
|
||||||
Roms with SHA-256: " + SHA256Count + @"
|
Roms with SHA-256: " + _sha256Count + @"
|
||||||
Roms with SHA-384: " + SHA384Count + @"
|
Roms with SHA-384: " + _sha384Count + @"
|
||||||
Roms with SHA-512: " + SHA512Count + "\n";
|
Roms with SHA-512: " + _sha512Count + "\n";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
{
|
{
|
||||||
line += " Roms with BadDump status: " + BaddumpCount + "\n";
|
line += " Roms with BadDump status: " + _baddumpCount + "\n";
|
||||||
}
|
}
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
{
|
{
|
||||||
line += " Roms with Nodump status: " + NodumpCount + "\n";
|
line += " Roms with Nodump status: " + _nodumpCount + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// For spacing between DATs
|
// For spacing between DATs
|
||||||
@@ -180,25 +271,25 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
if (outputs.ContainsKey(StatDatFormat.CSV))
|
if (outputs.ContainsKey(StatDatFormat.CSV))
|
||||||
{
|
{
|
||||||
line = "\"" + FileName + "\","
|
line = "\"" + _fileName + "\","
|
||||||
+ "\"" + TotalSize + "\","
|
+ "\"" + _totalSize + "\","
|
||||||
+ "\"" + (game == -1 ? Keys.Count() : game) + "\","
|
+ "\"" + (game == -1 ? Keys.Count() : game) + "\","
|
||||||
+ "\"" + RomCount + "\","
|
+ "\"" + _romCount + "\","
|
||||||
+ "\"" + DiskCount + "\","
|
+ "\"" + _diskCount + "\","
|
||||||
+ "\"" + CRCCount + "\","
|
+ "\"" + _crcCount + "\","
|
||||||
+ "\"" + MD5Count + "\","
|
+ "\"" + _md5Count + "\","
|
||||||
+ "\"" + SHA1Count + "\","
|
+ "\"" + _sha1Count + "\","
|
||||||
+ "\"" + SHA256Count + "\","
|
+ "\"" + _sha256Count + "\","
|
||||||
+ "\"" + SHA384Count + "\","
|
+ "\"" + _sha384Count + "\","
|
||||||
+ "\"" + SHA512Count + "\"";
|
+ "\"" + _sha512Count + "\"";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
{
|
{
|
||||||
line += ",\"" + BaddumpCount + "\"";
|
line += ",\"" + _baddumpCount + "\"";
|
||||||
}
|
}
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
{
|
{
|
||||||
line += ",\"" + NodumpCount + "\"";
|
line += ",\"" + _nodumpCount + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
line += "\n";
|
line += "\n";
|
||||||
@@ -206,25 +297,25 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
if (outputs.ContainsKey(StatDatFormat.HTML))
|
if (outputs.ContainsKey(StatDatFormat.HTML))
|
||||||
{
|
{
|
||||||
line = "\t\t\t<tr" + (FileName.StartsWith("DIR: ")
|
line = "\t\t\t<tr" + (_fileName.StartsWith("DIR: ")
|
||||||
? " class=\"dir\"><td>" + HttpUtility.HtmlEncode(FileName.Remove(0, 5))
|
? " class=\"dir\"><td>" + HttpUtility.HtmlEncode(_fileName.Remove(0, 5))
|
||||||
: "><td>" + HttpUtility.HtmlEncode(FileName)) + "</td>"
|
: "><td>" + HttpUtility.HtmlEncode(_fileName)) + "</td>"
|
||||||
+ "<td align=\"right\">" + Style.GetBytesReadable(TotalSize) + "</td>"
|
+ "<td align=\"right\">" + Style.GetBytesReadable(_totalSize) + "</td>"
|
||||||
+ "<td align=\"right\">" + (game == -1 ? Keys.Count() : game) + "</td>"
|
+ "<td align=\"right\">" + (game == -1 ? Keys.Count() : game) + "</td>"
|
||||||
+ "<td align=\"right\">" + RomCount + "</td>"
|
+ "<td align=\"right\">" + _romCount + "</td>"
|
||||||
+ "<td align=\"right\">" + DiskCount + "</td>"
|
+ "<td align=\"right\">" + _diskCount + "</td>"
|
||||||
+ "<td align=\"right\">" + CRCCount + "</td>"
|
+ "<td align=\"right\">" + _crcCount + "</td>"
|
||||||
+ "<td align=\"right\">" + MD5Count + "</td>"
|
+ "<td align=\"right\">" + _md5Count + "</td>"
|
||||||
+ "<td align=\"right\">" + SHA1Count + "</td>"
|
+ "<td align=\"right\">" + _sha1Count + "</td>"
|
||||||
+ "<td align=\"right\">" + SHA256Count + "</td>";
|
+ "<td align=\"right\">" + _sha256Count + "</td>";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
{
|
{
|
||||||
line += "<td align=\"right\">" + BaddumpCount + "</td>";
|
line += "<td align=\"right\">" + _baddumpCount + "</td>";
|
||||||
}
|
}
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
{
|
{
|
||||||
line += "<td align=\"right\">" + NodumpCount + "</td>";
|
line += "<td align=\"right\">" + _nodumpCount + "</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
line += "</tr>\n";
|
line += "</tr>\n";
|
||||||
@@ -232,25 +323,25 @@ namespace SabreTools.Library.Dats
|
|||||||
}
|
}
|
||||||
if (outputs.ContainsKey(StatDatFormat.TSV))
|
if (outputs.ContainsKey(StatDatFormat.TSV))
|
||||||
{
|
{
|
||||||
line = "\"" + FileName + "\"\t"
|
line = "\"" + _fileName + "\"\t"
|
||||||
+ "\"" + TotalSize + "\"\t"
|
+ "\"" + _totalSize + "\"\t"
|
||||||
+ "\"" + (game == -1 ? Keys.Count() : game) + "\"\t"
|
+ "\"" + (game == -1 ? Keys.Count() : game) + "\"\t"
|
||||||
+ "\"" + RomCount + "\"\t"
|
+ "\"" + _romCount + "\"\t"
|
||||||
+ "\"" + DiskCount + "\"\t"
|
+ "\"" + _diskCount + "\"\t"
|
||||||
+ "\"" + CRCCount + "\"\t"
|
+ "\"" + _crcCount + "\"\t"
|
||||||
+ "\"" + MD5Count + "\"\t"
|
+ "\"" + _md5Count + "\"\t"
|
||||||
+ "\"" + SHA1Count + "\"\t"
|
+ "\"" + _sha1Count + "\"\t"
|
||||||
+ "\"" + SHA256Count + "\"\t"
|
+ "\"" + _sha256Count + "\"\t"
|
||||||
+ "\"" + SHA384Count + "\"\t"
|
+ "\"" + _sha384Count + "\"\t"
|
||||||
+ "\"" + SHA512Count + "\"";
|
+ "\"" + _sha512Count + "\"";
|
||||||
|
|
||||||
if (baddumpCol)
|
if (baddumpCol)
|
||||||
{
|
{
|
||||||
line += "\t\"" + BaddumpCount + "\"";
|
line += "\t\"" + _baddumpCount + "\"";
|
||||||
}
|
}
|
||||||
if (nodumpCol)
|
if (nodumpCol)
|
||||||
{
|
{
|
||||||
line += "\t\"" + NodumpCount + "\"";
|
line += "\t\"" + _nodumpCount + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
line += "\n";
|
line += "\n";
|
||||||
@@ -334,6 +425,8 @@ namespace SabreTools.Library.Dats
|
|||||||
long totalMD5 = 0;
|
long totalMD5 = 0;
|
||||||
long totalSHA1 = 0;
|
long totalSHA1 = 0;
|
||||||
long totalSHA256 = 0;
|
long totalSHA256 = 0;
|
||||||
|
long totalSHA384 = 0;
|
||||||
|
long totalSHA512 = 0;
|
||||||
long totalBaddump = 0;
|
long totalBaddump = 0;
|
||||||
long totalNodump = 0;
|
long totalNodump = 0;
|
||||||
|
|
||||||
@@ -348,6 +441,8 @@ namespace SabreTools.Library.Dats
|
|||||||
long dirMD5 = 0;
|
long dirMD5 = 0;
|
||||||
long dirSHA1 = 0;
|
long dirSHA1 = 0;
|
||||||
long dirSHA256 = 0;
|
long dirSHA256 = 0;
|
||||||
|
long dirSHA384 = 0;
|
||||||
|
long dirSHA512 = 0;
|
||||||
long dirBaddump = 0;
|
long dirBaddump = 0;
|
||||||
long dirNodump = 0;
|
long dirNodump = 0;
|
||||||
|
|
||||||
@@ -366,16 +461,18 @@ namespace SabreTools.Library.Dats
|
|||||||
|
|
||||||
DatFile lastdirdat = new DatFile
|
DatFile lastdirdat = new DatFile
|
||||||
{
|
{
|
||||||
FileName = "DIR: " + HttpUtility.HtmlEncode(lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1))),
|
_fileName = "DIR: " + HttpUtility.HtmlEncode(lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1))),
|
||||||
TotalSize = dirSize,
|
_totalSize = dirSize,
|
||||||
RomCount = dirRom,
|
_romCount = dirRom,
|
||||||
DiskCount = dirDisk,
|
_diskCount = dirDisk,
|
||||||
CRCCount = dirCRC,
|
_crcCount = dirCRC,
|
||||||
MD5Count = dirMD5,
|
_md5Count = dirMD5,
|
||||||
SHA1Count = dirSHA1,
|
_sha1Count = dirSHA1,
|
||||||
SHA256Count = dirSHA256,
|
_sha256Count = dirSHA256,
|
||||||
BaddumpCount = dirBaddump,
|
_sha384Count = dirSHA384,
|
||||||
NodumpCount = dirNodump,
|
_sha512Count = dirSHA512,
|
||||||
|
_baddumpCount = dirBaddump,
|
||||||
|
_nodumpCount = dirNodump,
|
||||||
};
|
};
|
||||||
lastdirdat.OutputStats(outputs, statDatFormat,
|
lastdirdat.OutputStats(outputs, statDatFormat,
|
||||||
game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
||||||
@@ -395,6 +492,8 @@ namespace SabreTools.Library.Dats
|
|||||||
dirMD5 = 0;
|
dirMD5 = 0;
|
||||||
dirSHA1 = 0;
|
dirSHA1 = 0;
|
||||||
dirSHA256 = 0;
|
dirSHA256 = 0;
|
||||||
|
dirSHA384 = 0;
|
||||||
|
dirSHA512 = 0;
|
||||||
dirBaddump = 0;
|
dirBaddump = 0;
|
||||||
dirNodump = 0;
|
dirNodump = 0;
|
||||||
}
|
}
|
||||||
@@ -422,6 +521,8 @@ namespace SabreTools.Library.Dats
|
|||||||
dirMD5 += datdata.MD5Count;
|
dirMD5 += datdata.MD5Count;
|
||||||
dirSHA1 += datdata.SHA1Count;
|
dirSHA1 += datdata.SHA1Count;
|
||||||
dirSHA256 += datdata.SHA256Count;
|
dirSHA256 += datdata.SHA256Count;
|
||||||
|
dirSHA384 += datdata.SHA384Count;
|
||||||
|
dirSHA512 += datdata.SHA512Count;
|
||||||
dirBaddump += datdata.BaddumpCount;
|
dirBaddump += datdata.BaddumpCount;
|
||||||
dirNodump += datdata.NodumpCount;
|
dirNodump += datdata.NodumpCount;
|
||||||
|
|
||||||
@@ -434,6 +535,8 @@ namespace SabreTools.Library.Dats
|
|||||||
totalMD5 += datdata.MD5Count;
|
totalMD5 += datdata.MD5Count;
|
||||||
totalSHA1 += datdata.SHA1Count;
|
totalSHA1 += datdata.SHA1Count;
|
||||||
totalSHA256 += datdata.SHA256Count;
|
totalSHA256 += datdata.SHA256Count;
|
||||||
|
totalSHA384 += datdata.SHA384Count;
|
||||||
|
totalSHA512 += datdata.SHA512Count;
|
||||||
totalBaddump += datdata.BaddumpCount;
|
totalBaddump += datdata.BaddumpCount;
|
||||||
totalNodump += datdata.NodumpCount;
|
totalNodump += datdata.NodumpCount;
|
||||||
|
|
||||||
@@ -448,16 +551,18 @@ namespace SabreTools.Library.Dats
|
|||||||
{
|
{
|
||||||
DatFile dirdat = new DatFile
|
DatFile dirdat = new DatFile
|
||||||
{
|
{
|
||||||
FileName = "DIR: " + HttpUtility.HtmlEncode(lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1))),
|
_fileName = "DIR: " + HttpUtility.HtmlEncode(lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1))),
|
||||||
TotalSize = dirSize,
|
_totalSize = dirSize,
|
||||||
RomCount = dirRom,
|
_romCount = dirRom,
|
||||||
DiskCount = dirDisk,
|
_diskCount = dirDisk,
|
||||||
CRCCount = dirCRC,
|
_crcCount = dirCRC,
|
||||||
MD5Count = dirMD5,
|
_md5Count = dirMD5,
|
||||||
SHA1Count = dirSHA1,
|
_sha1Count = dirSHA1,
|
||||||
SHA256Count = dirSHA256,
|
_sha256Count = dirSHA256,
|
||||||
BaddumpCount = dirBaddump,
|
_sha384Count = dirSHA384,
|
||||||
NodumpCount = dirNodump,
|
_sha512Count = dirSHA512,
|
||||||
|
_baddumpCount = dirBaddump,
|
||||||
|
_nodumpCount = dirNodump,
|
||||||
};
|
};
|
||||||
dirdat.OutputStats(outputs, statDatFormat,
|
dirdat.OutputStats(outputs, statDatFormat,
|
||||||
game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
||||||
@@ -478,21 +583,25 @@ namespace SabreTools.Library.Dats
|
|||||||
dirMD5 = 0;
|
dirMD5 = 0;
|
||||||
dirSHA1 = 0;
|
dirSHA1 = 0;
|
||||||
dirSHA256 = 0;
|
dirSHA256 = 0;
|
||||||
|
dirSHA384 = 0;
|
||||||
|
dirSHA512 = 0;
|
||||||
dirNodump = 0;
|
dirNodump = 0;
|
||||||
|
|
||||||
// Output total DAT stats
|
// Output total DAT stats
|
||||||
DatFile totaldata = new DatFile
|
DatFile totaldata = new DatFile
|
||||||
{
|
{
|
||||||
FileName = "DIR: All DATs",
|
_fileName = "DIR: All DATs",
|
||||||
TotalSize = totalSize,
|
_totalSize = totalSize,
|
||||||
RomCount = totalRom,
|
_romCount = totalRom,
|
||||||
DiskCount = totalDisk,
|
_diskCount = totalDisk,
|
||||||
CRCCount = totalCRC,
|
_crcCount = totalCRC,
|
||||||
MD5Count = totalMD5,
|
_md5Count = totalMD5,
|
||||||
SHA1Count = totalSHA1,
|
_sha1Count = totalSHA1,
|
||||||
SHA256Count = totalSHA256,
|
_sha256Count = totalSHA256,
|
||||||
BaddumpCount = totalBaddump,
|
_sha384Count = totalSHA384,
|
||||||
NodumpCount = totalNodump,
|
_sha512Count = totalSHA512,
|
||||||
|
_baddumpCount = totalBaddump,
|
||||||
|
_nodumpCount = totalNodump,
|
||||||
};
|
};
|
||||||
totaldata.OutputStats(outputs, statDatFormat,
|
totaldata.OutputStats(outputs, statDatFormat,
|
||||||
game: totalGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
game: totalGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
||||||
|
|||||||
Reference in New Issue
Block a user