Tweak stats output and input handling

This commit is contained in:
Matt Nadareski
2020-07-23 11:40:45 -07:00
parent c47793fb57
commit e8e84f9762
3 changed files with 20 additions and 6 deletions

View File

@@ -426,7 +426,7 @@ namespace SabreTools.Library.DatFiles
outDir = DirectoryExtensions.Ensure(outDir); outDir = DirectoryExtensions.Ensure(outDir);
// Get the dictionary of desired output report names // Get the dictionary of desired output report names
Dictionary<StatReportFormat, string> outputs = DatStats.CreateOutStatsNames(outDir, statDatFormat, reportName); Dictionary<StatReportFormat, string> outputs = CreateOutStatsNames(outDir, statDatFormat, reportName);
// Make sure we have all files and then order them // Make sure we have all files and then order them
List<string> files = DirectoryExtensions.GetFilesOnly(inputs); List<string> files = DirectoryExtensions.GetFilesOnly(inputs);
@@ -551,7 +551,6 @@ Please check the log folder if the stats scrolled offscreen", false);
outDir += Path.DirectorySeparatorChar; outDir += Path.DirectorySeparatorChar;
// For each output format, get the appropriate stream writer // For each output format, get the appropriate stream writer
if (statDatFormat.HasFlag(StatReportFormat.None))
output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite)); output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite));
if (statDatFormat.HasFlag(StatReportFormat.Textfile)) if (statDatFormat.HasFlag(StatReportFormat.Textfile))

View File

@@ -29,7 +29,10 @@ namespace SabreTools.Library.Reports
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param> /// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
public BaseReport(string filename, bool baddumpCol = false, bool nodumpCol = false) public BaseReport(string filename, bool baddumpCol = false, bool nodumpCol = false)
{ {
_writer = new StreamWriter(FileExtensions.TryCreate(filename)); var fs = FileExtensions.TryCreate(filename);
if (fs != null)
_writer = new StreamWriter(fs);
_baddumpCol = baddumpCol; _baddumpCol = baddumpCol;
_nodumpCol = nodumpCol; _nodumpCol = nodumpCol;
} }

View File

@@ -3321,10 +3321,22 @@ The stats that are outputted are as follows:
public override void ProcessFeatures(Dictionary<string, Feature> features) public override void ProcessFeatures(Dictionary<string, Feature> features)
{ {
string filename = GetDatHeader(features).FileName;
string outputDir = GetString(features, OutputDirStringValue);
if (Path.GetFileName(filename) != filename)
{
if (string.IsNullOrWhiteSpace(outputDir))
outputDir = Path.GetDirectoryName(filename);
else
outputDir = Path.Combine(outputDir, Path.GetDirectoryName(filename));
filename = Path.GetFileName(filename);
}
DatStats.OutputStats( DatStats.OutputStats(
Inputs, Inputs,
GetDatHeader(features).FileName, filename,
GetString(features, OutputDirStringValue), outputDir,
GetBoolean(features, IndividualValue), GetBoolean(features, IndividualValue),
GetBoolean(features, BaddumpColumnValue), GetBoolean(features, BaddumpColumnValue),
GetBoolean(features, NodumpColumnValue), GetBoolean(features, NodumpColumnValue),