diff --git a/DATFromDir/DATFromDir.cs b/DATFromDir/DATFromDir.cs
index 3becd4d1..5adceed8 100644
--- a/DATFromDir/DATFromDir.cs
+++ b/DATFromDir/DATFromDir.cs
@@ -30,10 +30,9 @@ namespace SabreTools
private bool _noMD5;
private bool _noSHA1;
private bool _noDate;
- private bool _forceunzip;
+ private bool _forceunpack;
private bool _archivesAsFiles;
private bool _old;
- private bool _log;
private bool _superDat;
// User specified strings
@@ -59,13 +58,13 @@ namespace SabreTools
/// True if MD5 hashes should be skipped over, false otherwise
/// True if SHA-1 hashes should be skipped over, false otherwise
/// True if the date should be omitted from the DAT, false otherwise
- /// True if the forcepacking="unzip" tag is to be added, false otherwise
+ /// True if the forcepacking="unzip" tag is to be added, false otherwise
/// True if all archives should be treated like files, false otherwise
/// True if a old-style DAT should be output, false otherwise
/// True if SuperDAT mode is enabled, false otherwise
/// Logger object for console and file output
public DATFromDir(List inputs, string name, string desc, string cat, string version, string author,
- bool noMD5, bool noSHA1, bool noDate, bool forceunzip, bool archivesAsFiles, bool old, bool superDat, Logger logger)
+ bool noMD5, bool noSHA1, bool noDate, bool forceunpack, bool archivesAsFiles, bool old, bool superDat, Logger logger)
{
_inputs = inputs;
_name = name;
@@ -76,7 +75,7 @@ namespace SabreTools
_noMD5 = noMD5;
_noSHA1 = noSHA1;
_noDate = noDate;
- _forceunzip = forceunzip;
+ _forceunpack = forceunpack;
_archivesAsFiles = archivesAsFiles;
_old = old;
_superDat = superDat;
@@ -102,8 +101,8 @@ namespace SabreTools
logger.Start();
// First things first, take care of all of the arguments that this could have
- bool noMD5 = false, noSHA1 = false, forceunzip = false, allfiles = false, old = false, log = false, superDat = false, noDate = false;
- string name = "", desc = "", cat = "", version = "", author = "", basePath = "";
+ bool noMD5 = false, noSHA1 = false, forceunpack = false, archivesAsFiles = false, old = false, log = false, superDat = false, noDate = false;
+ string name = "", desc = "", cat = "", version = "", author = "";
List inputs = new List();
foreach (string arg in args)
{
@@ -129,11 +128,11 @@ namespace SabreTools
break;
case "-u":
case "--unzip":
- forceunzip = true;
+ forceunpack = true;
break;
case "-f":
case "--files":
- allfiles = true;
+ archivesAsFiles = true;
break;
case "-o":
case "--old":
@@ -203,7 +202,7 @@ namespace SabreTools
}
// Create a new DATFromDir object and process the inputs
- DATFromDir dfd = new DATFromDir(inputs, name, desc, cat, version, author, noMD5, noSHA1, noDate, forceunzip, allfiles, old, superDat, logger);
+ DATFromDir dfd = new DATFromDir(inputs, name, desc, cat, version, author, noMD5, noSHA1, noDate, forceunpack, archivesAsFiles, old, superDat, logger);
bool success = dfd.Start();
// If we failed, show the help
@@ -313,7 +312,7 @@ namespace SabreTools
_desc = (_desc == "" ? _name + (_noDate ? "" : " (" + _date + ")") : _desc);
// Now write it all out as a DAT
- Output.WriteToDat(_name, _desc, _version, _date, _cat, _author, _forceunzip, _old, Environment.CurrentDirectory, _roms, _logger);
+ Output.WriteToDat(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, Environment.CurrentDirectory, _roms, _logger);
return true;
}
diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs
index b2291ca3..4afd7c6c 100644
--- a/DATabase/DATabase.cs
+++ b/DATabase/DATabase.cs
@@ -226,10 +226,18 @@ namespace SabreTools
{
url = arg.Split('=')[1];
}
- else
+ else if (File.Exists(arg) || Directory.Exists(arg))
{
inputs.Add(arg);
}
+ else
+ {
+ logger.Warning("Invalid input detected: " + arg);
+ Console.WriteLine();
+ Build.Help();
+ logger.Close();
+ return;
+ }
break;
}
}
@@ -995,7 +1003,7 @@ Make a selection:
private static void TrimMergeMenu()
{
string selection = "", input = "", root = "";
- bool forceunzip = true, rename = true;
+ bool forceunpack = true, rename = true;
while (selection.ToLowerInvariant() != "b")
{
Console.Clear();
@@ -1006,7 +1014,7 @@ Make a selection:
1) File or folder to process" + (input != "" ? ":\n\t" + input : "") + @"
2) Root folder for reference" + (root != "" ? ":\n\t" + root : "") + @"
- 3) " + (forceunzip ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to output") + @"
+ 3) " + (forceunpack ? "Remove 'forcepacking=\"unzip\"' from output" : "Add 'forcepacking=\"unzip\"' to output") + @"
4) " + (rename ? "Disable game renaming" : "Enable game renaming") + @"
5) Process the file or folder
B) Go back to the previous menu
@@ -1026,14 +1034,14 @@ Make a selection:
root = Console.ReadLine();
break;
case "3":
- forceunzip = !forceunzip;
+ forceunpack = !forceunpack;
break;
case "4":
rename = !rename;
break;
case "5":
Console.Clear();
- InitTrimMerge(input, root, rename, forceunzip);
+ InitTrimMerge(input, root, rename, forceunpack);
Console.Write("\nPress any key to continue...");
Console.ReadKey();
break;
diff --git a/MergeDAT/MergeDAT.cs b/MergeDAT/MergeDAT.cs
index a247a354..5aea501e 100644
--- a/MergeDAT/MergeDAT.cs
+++ b/MergeDAT/MergeDAT.cs
@@ -8,24 +8,47 @@ namespace SabreTools
{
public class MergeDAT
{
- // Instance variables
+ // Listing related variables
+ private List _roms;
+ private List _inputs;
+
+ // User specified flags
private bool _diff;
private bool _dedup;
- private List _inputs;
+ private bool _noDate;
+ private bool _forceunpack;
+ private bool _old;
+
+ // User specified strings
+ private string _name;
+ private string _desc;
+ private string _cat;
+ private string _version;
+ private string _author;
+
+ // Other required variables
+ private string _date = DateTime.Now.ToString("yyyy-MM-dd");
private Logger _logger;
- ///
- /// Create a new MergeDAT object
- ///
/// A List of Strings representing the DATs or DAT folders to be merged
/// True if a DiffDat of all inputs is wanted, false otherwise
/// True if the outputted file should remove duplicates, false otherwise
/// Logger object for console and file output
- public MergeDAT(List inputs, bool diff, bool dedup, Logger logger)
+
+ public MergeDAT(List inputs, string name, string desc, string cat, string version, string author,
+ bool diff, bool dedup, bool noDate, bool forceunpack, bool old, Logger logger)
{
_inputs = inputs;
+ _name = name;
+ _desc = desc;
+ _cat = cat;
+ _version = version;
+ _author = author;
_diff = diff;
_dedup = dedup;
+ _noDate = noDate;
+ _forceunpack = forceunpack;
+ _old = old;
_logger = logger;
}
@@ -57,7 +80,8 @@ namespace SabreTools
Build.Start("DiffDat");
List inputs = new List();
- bool tofile = false, help = false, dedup = false, diff = false;
+ bool help = false, dedup = false, diff = false, forceunpack = false, old = false, log = false, noDate = false;
+ string name = "", desc = "", cat = "", version = "", author = "";
foreach (string arg in args)
{
switch (arg)
@@ -65,12 +89,9 @@ namespace SabreTools
case "-h":
case "-?":
case "--help":
- help = true;
- break;
- case "-l":
- case "--log":
- tofile = true;
- break;
+ Build.Help();
+ logger.Close();
+ return;
case "-di":
case "--diff":
diff = true;
@@ -79,9 +100,45 @@ namespace SabreTools
case "--dedup":
dedup = true;
break;
+ case "-b":
+ case "--bare":
+ noDate = true;
+ break;
+ case "-u":
+ case "--unzip":
+ forceunpack = true;
+ break;
+ case "-o":
+ case "--old":
+ old = true;
+ break;
+ case "-l":
+ case "--log":
+ log = true;
+ break;
default:
+ if (arg.StartsWith("-n=") || arg.StartsWith("--name="))
+ {
+ name = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("-d=") || arg.StartsWith("--desc="))
+ {
+ desc = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("-c=") || arg.StartsWith("--cat="))
+ {
+ cat = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("-a=") || arg.StartsWith("--author="))
+ {
+ author = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("-v=") || arg.StartsWith("--version="))
+ {
+ version = arg.Split('=')[1];
+ }
// Add actual files to the list of inputs
- if (File.Exists(arg.Replace("\"", "")))
+ else if (File.Exists(arg.Replace("\"", "")))
{
inputs.Add(Path.GetFullPath(arg.Replace("\"", "")));
}
@@ -97,7 +154,7 @@ namespace SabreTools
}
// Set the possibly new value for logger
- logger.ToFile = tofile;
+ logger.ToFile = log;
// Show help if explicitly asked for it or if not enough files are supplied
if (help || inputs.Count < 2)
@@ -108,7 +165,7 @@ namespace SabreTools
}
// Otherwise, read in the files, process them and write the result to the file type that the first one is
- MergeDAT md = new MergeDAT(inputs, diff, dedup, logger);
+ MergeDAT md = new MergeDAT(inputs, name, desc, cat, version, author, diff, dedup, noDate, forceunpack, old, logger);
md.MergeDiff();
}
@@ -150,14 +207,30 @@ namespace SabreTools
A = RomManipulation.Merge(A);
}
- if (_diff)
+ // Get the names that will be used
+ if (_name == "")
{
- Output.WriteToDat("diffdat" + (_dedup ? "-merged" : ""), "diffdat" + (_dedup ? "-merged" : ""), "", "", "DiffDat", "SabreTools", false, !RomManipulation.IsXmlDat(_inputs[0]), "", A, _logger);
+ _name = (_diff ? "diffdat" : "mergedat") + (_dedup ? "-merged" : "");
}
- else
+ if (_desc == "")
{
- Output.WriteToDat("combinedat" + (_dedup ? "-merged" : ""), "combinedat" + (_dedup ? "-merged" : ""), "", "", "", "SabreTools", false, !RomManipulation.IsXmlDat(_inputs[0]), "", A, _logger);
+ _desc = (_diff ? "diffdat" : "mergedat") + (_dedup ? "-merged" : "");
+ if (!_noDate)
+ {
+ _desc += " (" + _date + ")";
+ }
}
+ if (_cat == "" && _diff)
+ {
+ _cat = "DiffDAT";
+ }
+ if (_author == "")
+ {
+ _author = "SabreTools";
+ }
+
+ // Now write the file out
+ Output.WriteToDat(_name, _desc, _version, _date, _cat, _author, _forceunpack, _old, "", A, _logger);
return true;
}
diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs
index 6a7068bf..0008c1cf 100644
--- a/SabreHelper/Build.cs
+++ b/SabreHelper/Build.cs
@@ -89,7 +89,7 @@ Options:
url= URL (source only)
-cm, --convert-miss
-r, --roms Output roms to miss instead of sets
- -gp, --game-prefix Add game name as a prefix to each item
+ -gp, --game-prefix Add game name as a prefix to each item
-pre=, --prefix= Set prefix to be printed in front of all lines
-post=, --postfix= Set postfix to be printed behind all lines
-q, --quotes Put double-quotes around each item
@@ -165,7 +165,15 @@ Options:
-h, -?, --help Show this help dialog
-l, --log Enable log to file
-di, --diff Switch to diffdat mode
- -dd, --dedup Enable deduping in the created DAT");
+ -dd, --dedup Enable deduping in the created DAT
+ -b, --bare Don't include date in file name
+ -u, --unzip Force unzipping in created DAT
+ -o, --old Output DAT in RV format instead of XML
+ -n=, --name= Set the name of the DAT
+ -d=, --desc= Set the description of the DAT
+ -c=, --cat= Set the category of the DAT
+ -v=, --version= Set the version of the DAT
+ -a=, --author= Set the author of the DAT");
break;
default:
Console.Write("This is the default help output");
diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs
index 98b2874b..be4abdd4 100644
--- a/SabreHelper/Output.cs
+++ b/SabreHelper/Output.cs
@@ -17,13 +17,13 @@ namespace SabreTools.Helper
/// Usually the DAT creation date
/// Category of the DAT
/// DAT author
- /// Force all sets to be unzipped
+ /// Force all sets to be unzipped
/// Set output mode to old-style DAT
/// Set the output directory
/// List of RomData objects representing the games to be written out
/// Logger object for console and/or file output
/// Tru if the DAT was written correctly, false otherwise
- public static bool WriteToDat(string name, string description, string version, string date, string category, string author, bool forceunzip, bool old, string outDir, List roms, Logger logger)
+ public static bool WriteToDat(string name, string description, string version, string date, string category, string author, bool forceunpack, bool old, string outDir, List roms, Logger logger)
{
// If it's empty, use the current folder
if (outDir.Trim() == "")
@@ -51,7 +51,7 @@ namespace SabreTools.Helper
"\tversion \"" + HttpUtility.HtmlEncode(version) + "\"\n" +
"\tcomment \"\"\n" +
"\tauthor \"" + HttpUtility.HtmlEncode(author) + "\"\n" +
- (forceunzip ? "\tforcezipping no\n" : "") +
+ (forceunpack ? "\tforcezipping no\n" : "") +
")\n";
string header = "\n" +
@@ -64,7 +64,7 @@ namespace SabreTools.Helper
"\t\t\t" + HttpUtility.HtmlEncode(version) + "\n" +
"\t\t\t" + HttpUtility.HtmlEncode(date) + "\n" +
"\t\t\t" + HttpUtility.HtmlEncode(author) + "\n" +
- (forceunzip ? "\t\t\t\n" : "") +
+ (forceunpack ? "\t\t\t\n" : "") +
"\t\t\n";
// Write the header out