From 4f854a05b25f84f810116e4f6b57533412c06aeb Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 27 May 2016 09:38:25 -0700 Subject: [PATCH] Fully integrate stats into DATabase --- DATabase/DATabase.cs | 22 +++++++++++++++++++--- DATabase/Stats.cs | 9 ++++++--- SabreHelper/Build.cs | 2 ++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 06e29434..f83015f8 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -78,6 +78,8 @@ namespace SabreTools quotes = false, rem = false, romba = false, + single = false, + stats = false, superdat = false, trim = false, skip = false, @@ -223,6 +225,14 @@ namespace SabreTools case "--superdat": superdat = true; break; + case "-si": + case "--single": + single = true; + break; + case "-st": + case "--stats": + stats = true; + break; case "--skip": skip = true; break; @@ -331,7 +341,7 @@ namespace SabreTools // If more than one switch is enabled or help is set, show the help screen if (help || !(add ^ (convertMiss || romba) ^ convertCMP ^ convertRC ^ convertSD ^ convertXml ^ extsplit ^ generate ^ - genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ (merge || diff) ^ rem ^ trim)) + genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ (merge || diff) ^ rem ^ stats ^ trim)) { Build.Help(); logger.Close(); @@ -340,7 +350,7 @@ namespace SabreTools // If a switch that requires a filename is set and no file is, show the help screen if (inputs.Count == 0 && ((convertMiss || romba) || convertCMP || convertRC || convertSD - || convertXml || extsplit || hashsplit || import || (merge || diff) || trim)) + || convertXml || extsplit || hashsplit || import || (merge || diff) || stats || trim)) { Build.Help(); logger.Close(); @@ -491,6 +501,12 @@ namespace SabreTools InitHashSplit(inputs, outdir); } + // Get statistics on input files + else if (stats) + { + InitStats(inputs, single); + } + logger.Close(); return; } @@ -1729,7 +1745,7 @@ Make a selection: } } - Stats stats = new Stats(inputs, single, logger); + Stats stats = new Stats(newinputs, single, logger); stats.Process(); } diff --git a/DATabase/Stats.cs b/DATabase/Stats.cs index e55f1c46..7120ce2e 100644 --- a/DATabase/Stats.cs +++ b/DATabase/Stats.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.IO; using SabreTools.Helper; @@ -10,7 +9,7 @@ namespace SabreTools /// Get statistics on one or more DAT files /// /// Finish making this a proper object then port to DATabase (-st, --stats) - public class UncompressedSize + public class Stats { // Private instance variables private List _inputs; @@ -23,7 +22,7 @@ namespace SabreTools /// List of files and folders to parse /// True if single DAT stats are output, false otherwise /// Logger object for file and console output - public UncompressedSize(List inputs, bool single, Logger logger) + public Stats(List inputs, bool single, Logger logger) { _inputs = inputs; _single = single; @@ -115,6 +114,10 @@ namespace SabreTools Roms with Nodump status: " + singleNodump + @" "); } + else + { + _logger.User("Adding stats for file '" + filename + "'"); + } // Add single DAT stats to totals totalSize += singleSize; diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 6e07fb2b..2acbc300 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -132,6 +132,8 @@ Options: -rm, --remove Remove a system or source from the database -system= System ID -source= Source ID + -st, --stats Get statistics on all input DATs + -si, --single Show individual statistics -tm, --trim-merge Consolidate DAT into a single game and trim entries -rd=, --root-dir= Set the root directory for trimming calculation -nr, --no-rename Keep game names instead of using '!'