[DatFile] Correct outputs, add filename flag

This commit is contained in:
Matt Nadareski
2016-09-26 14:45:55 -07:00
parent e0c3623cbb
commit b565ef0c01
5 changed files with 35 additions and 30 deletions

View File

@@ -145,7 +145,8 @@ namespace SabreTools.Helper
helptext.Add(" -out= Output directory"); helptext.Add(" -out= Output directory");
helptext.Add(" -st, --stats Get statistics on all input DATs"); helptext.Add(" -st, --stats Get statistics on all input DATs");
helptext.Add(" -csv, --csv Output in Comma-Separated Value format"); helptext.Add(" -csv, --csv Output in Comma-Separated Value format");
helptext.Add(" -html, --html Write stats to HTML"); helptext.Add(" -f=, --filename= Set the filename for the output");
helptext.Add(" -html, --html Output in HTML format");
helptext.Add(" -si, --single Show individual statistics"); helptext.Add(" -si, --single Show individual statistics");
helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format"); helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format");
helptext.Add(" -ts, --type-split Split a DAT or folder by file types (rom/disk)"); helptext.Add(" -ts, --type-split Split a DAT or folder by file types (rom/disk)");

View File

@@ -5134,6 +5134,33 @@ namespace SabreTools.Helper
} }
} }
// Write the header, if any
string head = "";
switch (statOutputFormat)
{
case StatOutputFormat.CSV:
head = "\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1\",\"Nodumps\"\n";
break;
case StatOutputFormat.HTML:
head = @"<!DOCTYPE html>
<html>
<header>
<title>DAT Statistics Report</title>
</header>
<body>
<table border=""1"" cellpadding=""5"" cellspacing=""0"">
<tr><th>File Name</th><th>Total Size</th><th>Games</th><th>Roms</th><th>Disks</th><th>&#35; with CRC</th>"
+ "<th>&#35; with MD5</th><th>&#35; with SHA-1</th><th>Nodumps</th></tr>\n";
break;
case StatOutputFormat.None:
default:
break;
case StatOutputFormat.TSV:
head = "\"File Name\"\t\"Total Size\"\t\"Games\"\t\"Roms\"\t\"Disks\"\t\"# with CRC\"\t\"# with MD5\"\t\"# with SHA-1\"\t\"Nodumps\"\n";
break;
}
sw.Write(head);
// Init all total variables // Init all total variables
long totalSize = 0; long totalSize = 0;
long totalGame = 0; long totalGame = 0;
@@ -5157,32 +5184,6 @@ namespace SabreTools.Helper
logger.User("Adding stats for file '" + filename + "'\n", false); logger.User("Adding stats for file '" + filename + "'\n", false);
if (single) if (single)
{ {
string line = "";
switch (statOutputFormat)
{
case StatOutputFormat.CSV:
line = "\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1\",\"Nodumps\"\n";
break;
case StatOutputFormat.HTML:
line = @"<!DOCTYPE html>
<html>
<header>
<title>DAT Statistics Report</title>
</header>
<body>
<table border=""1"" cellpadding=""5"" cellspacing=""0"">
<tr><th>File Name</th><th>Total Size</th><th>Games</th><th>Roms</th><th>Disks</th><th>&#35; with CRC</th>"
+ "<th>&#35; with MD5</th><th>&#35; with SHA-1</th><th>Nodumps</th></tr>\n";
break;
case StatOutputFormat.None:
default:
break;
case StatOutputFormat.TSV:
line = "\"File Name\"\t\"Total Size\"\t\"Games\"\t\"Roms\"\t\"Disks\"\t\"# with CRC\"\t\"# with MD5\"\t\"# with SHA-1\"\t\"Nodumps\"\n";
break;
}
sw.Write(line);
datdata.OutputStats(sw, statOutputFormat, logger); datdata.OutputStats(sw, statOutputFormat, logger);
} }

View File

@@ -325,6 +325,9 @@ Options:
-csv, --csv Write all statistics to CSV -csv, --csv Write all statistics to CSV
Output all rom information in standardized CSV format Output all rom information in standardized CSV format
-f=, --filename= Set the filename for the output
Set the filename (without extension) for the outputted report
-html, --html Write all statistics to HTML -html, --html Write all statistics to HTML
This will output by default the combined statistics for all input DAT files. This will output by default the combined statistics for all input DAT files.

View File

@@ -285,9 +285,9 @@ namespace SabreTools
/// <param name="inputs">List of inputs to be used</param> /// <param name="inputs">List of inputs to be used</param>
/// <param name="single">True to show individual DAT statistics, false otherwise</param> /// <param name="single">True to show individual DAT statistics, false otherwise</param>
/// <param name="statOutputFormat">Set the statistics output format to use</param> /// <param name="statOutputFormat">Set the statistics output format to use</param>
private static void InitStats(List<string> inputs, bool single, StatOutputFormat statOutputFormat) private static void InitStats(List<string> inputs, string filename, bool single, StatOutputFormat statOutputFormat)
{ {
DatFile.OutputStats(inputs, "report", single, statOutputFormat, _logger); DatFile.OutputStats(inputs, (String.IsNullOrEmpty(filename) ? "report" : filename), single, statOutputFormat, _logger);
} }
/// <summary> /// <summary>

View File

@@ -574,7 +574,7 @@ namespace SabreTools
// Get statistics on input files // Get statistics on input files
else if (stats) else if (stats)
{ {
InitStats(inputs, single, statOutputFormat); InitStats(inputs, filename, single, statOutputFormat);
} }
// Split a DAT by item type // Split a DAT by item type