mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Slightly more updates on making this look better
This commit is contained in:
@@ -5171,24 +5171,24 @@ namespace SabreTools.Helper
|
|||||||
StreamWriter sw = new StreamWriter(File.Open(reportName, FileMode.Create, FileAccess.Write));
|
StreamWriter sw = new StreamWriter(File.Open(reportName, FileMode.Create, FileAccess.Write));
|
||||||
|
|
||||||
// Make sure we have all files
|
// Make sure we have all files
|
||||||
List<string> newinputs = new List<string>();
|
List<Tuple<string, string>> newinputs = new List<Tuple<string, string>>(); // item, basepath
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
{
|
{
|
||||||
if (File.Exists(input))
|
if (File.Exists(input))
|
||||||
{
|
{
|
||||||
newinputs.Add(Path.GetFullPath(input));
|
newinputs.Add(Tuple.Create(Path.GetFullPath(input), Path.GetDirectoryName(Path.GetFullPath(input))));
|
||||||
}
|
}
|
||||||
if (Directory.Exists(input))
|
if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
foreach (string file in Directory.GetFiles(input, "*", SearchOption.AllDirectories))
|
foreach (string file in Directory.GetFiles(input, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
newinputs.Add(Path.GetFullPath(file));
|
newinputs.Add(Tuple.Create(Path.GetFullPath(file), Path.GetFullPath(input)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newinputs = newinputs
|
newinputs = newinputs
|
||||||
.OrderBy(i => Path.GetDirectoryName(i))
|
.OrderBy(i => Path.GetDirectoryName(i.Item1))
|
||||||
.ThenBy(i => Path.GetFileName(i))
|
.ThenBy(i => Path.GetFileName(i.Item1))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Write the header, if any
|
// Write the header, if any
|
||||||
@@ -5207,6 +5207,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
// Init directory-level variables
|
// Init directory-level variables
|
||||||
string lastdir = null;
|
string lastdir = null;
|
||||||
|
string basepath = null;
|
||||||
long dirSize = 0;
|
long dirSize = 0;
|
||||||
long dirGame = 0;
|
long dirGame = 0;
|
||||||
long dirRom = 0;
|
long dirRom = 0;
|
||||||
@@ -5218,10 +5219,11 @@ namespace SabreTools.Helper
|
|||||||
long dirNodump = 0;
|
long dirNodump = 0;
|
||||||
|
|
||||||
// Now process each of the input files
|
// Now process each of the input files
|
||||||
foreach (string filename in newinputs)
|
foreach (Tuple<string, string> filename in newinputs)
|
||||||
{
|
{
|
||||||
// Get the directory for the current file
|
// Get the directory for the current file
|
||||||
string thisdir = Path.GetDirectoryName(filename);
|
string thisdir = Path.GetDirectoryName(filename.Item1);
|
||||||
|
basepath = Path.GetDirectoryName(filename.Item2);
|
||||||
|
|
||||||
// If we don't have the first file and the directory has changed, show the previous directory stats and reset
|
// If we don't have the first file and the directory has changed, show the previous directory stats and reset
|
||||||
if (lastdir != null && thisdir != lastdir)
|
if (lastdir != null && thisdir != lastdir)
|
||||||
@@ -5231,7 +5233,7 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
DatFile lastdirdat = new DatFile
|
DatFile lastdirdat = new DatFile
|
||||||
{
|
{
|
||||||
FileName = lastdir,
|
FileName = lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1)),
|
||||||
TotalSize = dirSize,
|
TotalSize = dirSize,
|
||||||
RomCount = dirRom,
|
RomCount = dirRom,
|
||||||
DiskCount = dirDisk,
|
DiskCount = dirDisk,
|
||||||
@@ -5244,10 +5246,10 @@ namespace SabreTools.Helper
|
|||||||
lastdirdat.OutputStats(sw, statOutputFormat, logger, game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
lastdirdat.OutputStats(sw, statOutputFormat, logger, game: dirGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
||||||
|
|
||||||
// Write the mid-footer, if any
|
// Write the mid-footer, if any
|
||||||
OutputStatsWriteMidFooter(sw, statOutputFormat);
|
OutputStatsWriteMidFooter(sw, statOutputFormat, baddumpCol, nodumpCol);
|
||||||
|
|
||||||
// Write the header, if any
|
// Write the header, if any
|
||||||
OutputStatsWriteHeader(sw, statOutputFormat, baddumpCol, nodumpCol);
|
OutputStatsWriteMidHeader(sw, statOutputFormat, baddumpCol, nodumpCol);
|
||||||
|
|
||||||
// Reset the directory stats
|
// Reset the directory stats
|
||||||
dirSize = 0;
|
dirSize = 0;
|
||||||
@@ -5264,7 +5266,7 @@ namespace SabreTools.Helper
|
|||||||
logger.Verbose("Beginning stat collection for '" + filename + "'", false);
|
logger.Verbose("Beginning stat collection for '" + filename + "'", false);
|
||||||
List<string> games = new List<string>();
|
List<string> games = new List<string>();
|
||||||
DatFile datdata = new DatFile();
|
DatFile datdata = new DatFile();
|
||||||
datdata.Parse(filename, 0, 0, logger);
|
datdata.Parse(filename.Item1, 0, 0, logger);
|
||||||
datdata.BucketByGame(false, true, logger, false);
|
datdata.BucketByGame(false, true, logger, false);
|
||||||
|
|
||||||
// Output single DAT stats (if asked)
|
// Output single DAT stats (if asked)
|
||||||
@@ -5307,7 +5309,7 @@ namespace SabreTools.Helper
|
|||||||
{
|
{
|
||||||
DatFile dirdat = new DatFile
|
DatFile dirdat = new DatFile
|
||||||
{
|
{
|
||||||
FileName = lastdir,
|
FileName = lastdir.Remove(0, basepath.Length + (basepath.Length == 0 ? 0 : 1)),
|
||||||
TotalSize = dirSize,
|
TotalSize = dirSize,
|
||||||
RomCount = dirRom,
|
RomCount = dirRom,
|
||||||
DiskCount = dirDisk,
|
DiskCount = dirDisk,
|
||||||
@@ -5321,10 +5323,10 @@ namespace SabreTools.Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the mid-footer, if any
|
// Write the mid-footer, if any
|
||||||
OutputStatsWriteMidFooter(sw, statOutputFormat);
|
OutputStatsWriteMidFooter(sw, statOutputFormat, baddumpCol, nodumpCol);
|
||||||
|
|
||||||
// Write the header, if any
|
// Write the header, if any
|
||||||
OutputStatsWriteHeader(sw, statOutputFormat, baddumpCol, nodumpCol);
|
OutputStatsWriteMidHeader(sw, statOutputFormat, baddumpCol, nodumpCol);
|
||||||
|
|
||||||
// Reset the directory stats
|
// Reset the directory stats
|
||||||
dirSize = 0;
|
dirSize = 0;
|
||||||
@@ -5349,7 +5351,7 @@ namespace SabreTools.Helper
|
|||||||
BaddumpCount = totalBaddump,
|
BaddumpCount = totalBaddump,
|
||||||
NodumpCount = totalNodump,
|
NodumpCount = totalNodump,
|
||||||
};
|
};
|
||||||
totaldata.OutputStats(sw, statOutputFormat, logger, game: totalGame);
|
totaldata.OutputStats(sw, statOutputFormat, logger, game: totalGame, baddumpCol: baddumpCol, nodumpCol: nodumpCol);
|
||||||
|
|
||||||
// Output footer if needed
|
// Output footer if needed
|
||||||
OutputStatsWriteFooter(sw, statOutputFormat);
|
OutputStatsWriteFooter(sw, statOutputFormat);
|
||||||
@@ -5401,8 +5403,6 @@ Please check the log folder if the stats scrolled offscreen", false);
|
|||||||
switch (statOutputFormat)
|
switch (statOutputFormat)
|
||||||
{
|
{
|
||||||
case StatOutputFormat.CSV:
|
case StatOutputFormat.CSV:
|
||||||
head = "\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1\""
|
|
||||||
+ (baddumpCol ? ",\"BadDumps\"" : "") + (nodumpCol ? ",\"Nodumps\"" : "") + "\n";
|
|
||||||
break;
|
break;
|
||||||
case StatOutputFormat.HTML:
|
case StatOutputFormat.HTML:
|
||||||
head = @"<!DOCTYPE html>
|
head = @"<!DOCTYPE html>
|
||||||
@@ -5412,7 +5412,38 @@ Please check the log folder if the stats scrolled offscreen", false);
|
|||||||
</header>
|
</header>
|
||||||
<body>
|
<body>
|
||||||
<table border=""1"" cellpadding=""5"" cellspacing=""0"">
|
<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># with CRC</th>"
|
";
|
||||||
|
break;
|
||||||
|
case StatOutputFormat.None:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case StatOutputFormat.TSV:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sw.Write(head);
|
||||||
|
|
||||||
|
// Now write the mid header for those who need it
|
||||||
|
OutputStatsWriteMidHeader(sw, statOutputFormat, baddumpCol, nodumpCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Write out the mid-header to the stream, if any exists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sw">StreamWriter representing the output</param>
|
||||||
|
/// <param name="statOutputFormat">StatOutputFormat representing output format</param>
|
||||||
|
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
||||||
|
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||||
|
private static void OutputStatsWriteMidHeader(StreamWriter sw, StatOutputFormat statOutputFormat, bool baddumpCol, bool nodumpCol)
|
||||||
|
{
|
||||||
|
string head = "";
|
||||||
|
switch (statOutputFormat)
|
||||||
|
{
|
||||||
|
case StatOutputFormat.CSV:
|
||||||
|
head = "\"File Name\",\"Total Size\",\"Games\",\"Roms\",\"Disks\",\"# with CRC\",\"# with MD5\",\"# with SHA-1\""
|
||||||
|
+ (baddumpCol ? ",\"BadDumps\"" : "") + (nodumpCol ? ",\"Nodumps\"" : "") + "\n";
|
||||||
|
break;
|
||||||
|
case StatOutputFormat.HTML:
|
||||||
|
head = @" <tr><th>File Name</th><th>Total Size</th><th>Games</th><th>Roms</th><th>Disks</th><th># with CRC</th>"
|
||||||
+ "<th># with MD5</th><th># with SHA-1</th>" + (baddumpCol ? "<th>Baddumps</th>" : "") + (nodumpCol ? "<th>Nodumps</th>" : "") + "</tr>\n";
|
+ "<th># with MD5</th><th># with SHA-1</th>" + (baddumpCol ? "<th>Baddumps</th>" : "") + (nodumpCol ? "<th>Nodumps</th>" : "") + "</tr>\n";
|
||||||
break;
|
break;
|
||||||
case StatOutputFormat.None:
|
case StatOutputFormat.None:
|
||||||
@@ -5462,7 +5493,9 @@ Please check the log folder if the stats scrolled offscreen", false);
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sw">StreamWriter representing the output</param>
|
/// <param name="sw">StreamWriter representing the output</param>
|
||||||
/// <param name="statOutputFormat">StatOutputFormat representing output format</param>
|
/// <param name="statOutputFormat">StatOutputFormat representing output format</param>
|
||||||
private static void OutputStatsWriteMidFooter(StreamWriter sw, StatOutputFormat statOutputFormat)
|
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
||||||
|
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||||
|
private static void OutputStatsWriteMidFooter(StreamWriter sw, StatOutputFormat statOutputFormat, bool baddumpCol, bool nodumpCol)
|
||||||
{
|
{
|
||||||
string end = "";
|
string end = "";
|
||||||
switch (statOutputFormat)
|
switch (statOutputFormat)
|
||||||
@@ -5471,8 +5504,14 @@ Please check the log folder if the stats scrolled offscreen", false);
|
|||||||
end = "\n";
|
end = "\n";
|
||||||
break;
|
break;
|
||||||
case StatOutputFormat.HTML:
|
case StatOutputFormat.HTML:
|
||||||
end = @" </table>
|
end = "<tr border=\"0\"><td colspan=\""
|
||||||
<p/>";
|
+ (baddumpCol && nodumpCol
|
||||||
|
? "11"
|
||||||
|
: (baddumpCol ^ nodumpCol
|
||||||
|
? "10"
|
||||||
|
: "9")
|
||||||
|
)
|
||||||
|
+ "\"></td></tr>\n";
|
||||||
break;
|
break;
|
||||||
case StatOutputFormat.None:
|
case StatOutputFormat.None:
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user