diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index fae4e3c9..da8804b0 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -494,7 +494,7 @@ namespace SabreTools // Merge, diff, and dedupe at least 2 DATs else if (merge || diff) { - InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat, cascade, inplace); + InitMergeDiff(inputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat, cascade, inplace, outdir); } // Split a DAT by available hashes @@ -1627,7 +1627,7 @@ Make a selection: /// True if the outputted diffs should be cascaded, false otherwise /// True if cascaded diffs overwrite the source files, false otherwise private static void InitMergeDiff(List inputs, string name, string desc, string cat, string version, string author, - bool diff, bool dedup, bool bare, bool forceunpack, bool old, bool superdat, bool cascade, bool inplace) + bool diff, bool dedup, bool bare, bool forceunpack, bool old, bool superdat, bool cascade, bool inplace, string outdir = "") { // Make sure there are no folders in inputs List newInputs = new List(); @@ -1639,7 +1639,7 @@ Make a selection: { try { - newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(file.Replace("\"", ""))); + newInputs.Add(Path.GetFullPath(file) + "¬" + Path.GetFullPath(input.Replace("\"", ""))); } catch (PathTooLongException) { @@ -1660,7 +1660,7 @@ Make a selection: } } - MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat, cascade, inplace, logger); + MergeDiff md = new MergeDiff(newInputs, name, desc, cat, version, author, diff, dedup, bare, forceunpack, old, superdat, cascade, inplace, outdir, logger); md.Process(); } diff --git a/DATabase/MergeDiff.cs b/DATabase/MergeDiff.cs index 4c17f7ed..2140b07c 100644 --- a/DATabase/MergeDiff.cs +++ b/DATabase/MergeDiff.cs @@ -28,6 +28,7 @@ namespace SabreTools private string _cat; private string _version; private string _author; + private string _outdir; // Other required variables private string _date = DateTime.Now.ToString("yyyy-MM-dd"); @@ -51,9 +52,10 @@ namespace SabreTools /// True if DATs should be parsed into SuperDAT format, false otherwise /// True if the outputted diffs should be cascaded, false otherwise /// True if cascaded diffs overwrite the source files, false otherwise + /// New output directory for outputted DATs (blank means default) /// Logger object for console and file output public MergeDiff(List inputs, string name, string desc, string cat, string version, string author, - bool diff, bool dedup, bool bare, bool forceunpack, bool old, bool superdat, bool cascade, bool inplace, Logger logger) + bool diff, bool dedup, bool bare, bool forceunpack, bool old, bool superdat, bool cascade, bool inplace, string outdir, Logger logger) { _inputs = inputs; _name = name; @@ -69,6 +71,7 @@ namespace SabreTools _superdat = superdat; _cascade = cascade; _inplace = inplace; + _outdir = outdir.Replace("\"", ""); _logger = logger; } @@ -211,7 +214,7 @@ namespace SabreTools } // Output the difflist (a-b)+(b-a) diff - Output.WriteDatfile(outerDiffData, "", _logger); + Output.WriteDatfile(outerDiffData, _outdir, _logger); // For the AB mode-style diffs, get all required dictionaries and output with a new name // Loop through _inputs first and filter from all diffed roms to find the ones that have the same "System" @@ -253,7 +256,7 @@ namespace SabreTools } } - Output.WriteDatfile(diffData, "", _logger); + Output.WriteDatfile(diffData, _outdir, _logger); } // Get all entries that have External dupes @@ -295,7 +298,7 @@ namespace SabreTools } } - Output.WriteDatfile(dupeData, "", _logger); + Output.WriteDatfile(dupeData, _outdir, _logger); } // If we're in cascade and diff, output only cascaded diffs else if (_diff && _cascade) @@ -359,7 +362,18 @@ namespace SabreTools userData.Roms[key] = newroms; } - Output.WriteDatfile(diffData, (_inplace ? _inputs[j].Split('¬')[1] : ""), _logger); + // If we have an output directory set, replace the path + string path = ""; + if (_inplace) + { + path = Path.GetDirectoryName(_inputs[j].Split('¬')[0]); + } + else if (!String.IsNullOrEmpty(_outdir)) + { + path = _outdir + (_inputs[j].Split('¬')[0].Remove(0, _inputs[j].Split('¬')[1].Length)); + } + + Output.WriteDatfile(diffData, path, _logger); } } // Output all entries with user-defined merge @@ -388,7 +402,7 @@ namespace SabreTools } } - Output.WriteDatfile(userData, "", _logger); + Output.WriteDatfile(userData, _outdir, _logger); } return true; diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 2acbc300..5b85e2d0 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -123,6 +123,7 @@ Options: -b, --bare Don't include date in file name -u, --unzip Force unzipping in created DAT -o, --old Output DAT in CMP format instead of XML + -out= Output directory (overridden by --cascade) -sd, --superdat Enable SuperDAT creation -n=, --name= Set the internal name of the DAT -d=, --desc= Set the filename and description of the DAT