diff --git a/HashSplit/HashSplit.cs b/HashSplit/HashSplit.cs index 818173a4..c72145ac 100644 --- a/HashSplit/HashSplit.cs +++ b/HashSplit/HashSplit.cs @@ -13,16 +13,19 @@ namespace SabreTools { // Internal variables List _inputs; + string _outdir; Logger _logger; /// /// Create a HashSplit object /// /// The name of the file to be split + /// Optional output directory, defaults to DAT directory /// Logger object for file and console output - public HashSplit(List inputs, Logger logger) + public HashSplit(List inputs, string outdir, Logger logger) { _inputs = inputs; + _outdir = (outdir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? outdir : outdir + Path.DirectorySeparatorChar).Replace("\"", ""); _logger = logger; } @@ -45,6 +48,7 @@ namespace SabreTools logger.Start(); // First things first, take care of all of the arguments that this could have + string outdir = ""; List inputs = new List(); foreach (string arg in args) { @@ -57,7 +61,14 @@ namespace SabreTools logger.Close(); return; default: - inputs.Add(arg); + if (arg.StartsWith("out=")) + { + outdir = arg.Split('=')[1]; + } + else + { + inputs.Add(arg); + } break; } } @@ -86,7 +97,7 @@ namespace SabreTools } // If so, run the program - HashSplit hs = new HashSplit(inputs, logger); + HashSplit hs = new HashSplit(inputs, outdir, logger); hs.Split(); } @@ -110,13 +121,13 @@ namespace SabreTools { if (File.Exists(input)) { - finalreturn &= SplitHelper(input); + finalreturn &= SplitHelper(input, Path.GetDirectoryName(input)); } if (Directory.Exists(input)) { foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories)) { - finalreturn &= SplitHelper(Path.GetFullPath(file)); + finalreturn &= SplitHelper(Path.GetFullPath(file), (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar)); } } } @@ -124,7 +135,7 @@ namespace SabreTools return finalreturn; } - private bool SplitHelper(string filename) + private bool SplitHelper(string filename, string basepath) { // Get the file data to be split OutputFormat outputFormat = RomManipulation.GetOutputFormat(filename); @@ -252,11 +263,20 @@ namespace SabreTools } } - bool success = true; + // Get the output directory + string outdir = ""; + if (_outdir != "") + { + outdir = _outdir + Path.GetDirectoryName(filename).Remove(0, filename.Length); + } + else + { + outdir = Path.GetDirectoryName(filename); + } - // Now, output all of the files to the original location + // Now, output all of the files to the output directory _logger.User("DAT information created, outputting new files"); - string outdir = Path.GetDirectoryName(filename); + bool success = true; success &= Output.WriteDatfile(sha1, outdir, _logger); success &= Output.WriteDatfile(md5, outdir, _logger); success &= Output.WriteDatfile(crc, outdir, _logger); diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index b110d64e..33cdacde 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -215,10 +215,11 @@ Options: case "HashSplit": Console.WriteLine(@"HashSplit - Split a DAT by best-available hashes ----------------------------------------- -Usage: DATabaseTwo [options] filename +Usage: HashSplit [options] [filename|dirname] ... Options: -h, -?, --help Show this help dialog + -out= Output directory "); break; default: diff --git a/SabreHelper/sqlite3.dll b/SabreHelper/sqlite3.dll index fcac1b2d..2797682c 100644 Binary files a/SabreHelper/sqlite3.dll and b/SabreHelper/sqlite3.dll differ