diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index ed17581b..cd883a8d 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -240,6 +240,7 @@ namespace SabreTools.Helper.Data helptext.Add(" -bc, --baddump-col Add baddump stats to output"); helptext.Add(" -csv, --csv Output in Comma-Separated Value format"); helptext.Add(" -f=, --filename= Set the filename for the output"); + helptext.Add(" -out= Output directory"); helptext.Add(" -html, --html Output in HTML format"); helptext.Add(" -nc, --nodump-col Add nodump stats to output"); helptext.Add(" -si, --single Show individual statistics"); diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs index eab33abd..ad8ffbcd 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs @@ -234,10 +234,23 @@ namespace SabreTools.Helper.Dats /// True if nodumps should be included in output, false otherwise /// Set the statistics output format to use /// Logger object for file and console output - public static void OutputStats(List inputs, string reportName, bool single, bool baddumpCol, - bool nodumpCol, StatDatFormat statDatFormat, Logger logger) + public static void OutputStats(List inputs, string reportName, string outDir, bool single, + bool baddumpCol, bool nodumpCol, StatDatFormat statDatFormat, Logger logger) { - reportName += OutputStatsGetExtension(statDatFormat); + // Get the proper output file name + if (String.IsNullOrEmpty(outDir)) + { + outDir = Environment.CurrentDirectory; + } + if (String.IsNullOrEmpty(reportName)) + { + reportName = "report"; + } + outDir = Path.GetFullPath(outDir); + reportName = Style.GetFileNameWithoutExtension(reportName) + OutputStatsGetExtension(statDatFormat); + Path.Combine(outDir, reportName); + + // Create the StreamWriter for this file StreamWriter sw = new StreamWriter(File.Open(reportName, FileMode.Create, FileAccess.Write)); // Make sure we have all files diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index ea3bf636..4876a240 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -505,6 +505,10 @@ Options: -f=, --filename= Set the filename for the output Set the filename (without extension) for the outputted report + -out= Set the name of the output directory + This sets an output folder to be used when the files are created. If a path + is not defined, the application directory is used instead. + -html, --html Write all statistics to HTML This will output by default the combined statistics for all input DAT files. diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 63cff6e3..c0bd347a 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -341,13 +341,14 @@ namespace SabreTools /// /// List of inputs to be used /// Name of the file to output to, blank for default + /// Output directory for the report files /// True to show individual DAT statistics, false otherwise /// True if baddumps should be included in output, false otherwise /// True if nodumps should be included in output, false otherwise /// Set the statistics output format to use - private static void InitStats(List inputs, string filename, bool single, bool baddumpCol, bool nodumpCol, StatDatFormat statDatFormat) + private static void InitStats(List inputs, string filename, string outDir, bool single, bool baddumpCol, bool nodumpCol, StatDatFormat statDatFormat) { - DatFile.OutputStats(inputs, (String.IsNullOrEmpty(filename) ? "report" : filename), single, baddumpCol, nodumpCol, statDatFormat, _logger); + DatFile.OutputStats(inputs, filename, outDir, single, baddumpCol, nodumpCol, statDatFormat, _logger); } /// diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 14e60aa7..736be07c 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -1021,7 +1021,7 @@ namespace SabreTools // Get statistics on input files else if (stats) { - InitStats(inputs, filename, single, showBaddumpColumn, showNodumpColumn, statDatFormat); + InitStats(inputs, filename, outDir, single, showBaddumpColumn, showNodumpColumn, statDatFormat); } // Convert, update, merge, diff, and filter a DAT or folder of DATs