diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs
index ada09df1..47aed4ad 100644
--- a/DATabase/DATabase.cs
+++ b/DATabase/DATabase.cs
@@ -54,6 +54,7 @@ namespace SabreTools
convertRV = false,
convertXml = false,
disableForce = false,
+ extsplit = false,
generate = false,
genall = false,
import = false,
@@ -65,7 +66,9 @@ namespace SabreTools
rem = false,
trim = false,
skip = false;
- string manu = "",
+ string exta = "",
+ extb = "",
+ manu = "",
outdir = "",
sources = "",
systems = "",
@@ -97,7 +100,11 @@ namespace SabreTools
break;
case "-df":
case "--disable-force":
- disableForce = false;
+ disableForce = true;
+ break;
+ case "-es":
+ case "--ext-split":
+ extsplit = true;
break;
case "-g":
case "--generate":
@@ -143,7 +150,15 @@ namespace SabreTools
trim = true;
break;
default:
- if (arg.StartsWith("input="))
+ if (arg.StartsWith("exta="))
+ {
+ exta = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("extb"))
+ {
+ extb = arg.Split('=')[1];
+ }
+ else if (arg.StartsWith("input="))
{
inputs.Add(arg.Split('=')[1]);
}
@@ -186,7 +201,7 @@ namespace SabreTools
}
// If more than one switch is enabled or help is set, show the help screen
- if (help || !(add ^ convertRV ^ convertXml ^ generate ^ genall ^ import ^ listsrc ^ listsys ^ rem ^ trim))
+ if (help || !(add ^ convertRV ^ convertXml ^ extsplit ^ generate ^ genall ^ import ^ listsrc ^ listsys ^ rem ^ trim))
{
Build.Help();
logger.Close();
@@ -194,7 +209,7 @@ namespace SabreTools
}
// If a switch that requires a filename is set and no file is, show the help screen
- if (inputs.Count == 0 && (convertRV || convertXml || import || trim))
+ if (inputs.Count == 0 && (convertRV || convertXml || extsplit || import || trim))
{
Build.Help();
logger.Close();
@@ -667,6 +682,7 @@ Make a selection:
1) Convert XML DAT to RV
2) Convert RV DAT to XML
3) Trim all entries in DAT and merge into a single game
+ 4) Split DAT using 2 extensions
B) Go back to the previous menu
");
Console.Write("Enter selection: ");
@@ -682,6 +698,9 @@ Make a selection:
case "3":
TrimMergeMenu();
break;
+ case "4":
+ ExtSplitMenu();
+ break;
}
}
}
@@ -871,6 +890,81 @@ Make a selection:
}
}
+ ///
+ /// Show the text-based ExtSplit menu
+ ///
+ private static void ExtSplitMenu()
+ {
+ string selection = "", input = "", exta = "", extb = "", outdir = "";
+ while (selection.ToLowerInvariant() != "b")
+ {
+ Console.Clear();
+ Build.Start("DATabase");
+ Console.WriteLine(@"EXTENSION SPLIT MENU
+===========================
+Make a selection:
+
+ 1) File to split" + (input != "" ? ":\n\t" + input : "") + @"
+ 2) First file extension" + (exta != "" ? ":\t" + exta : "") + @"
+ 3) Second file extension" + (extb != "" ? ":\t" + extb : "") + @"
+ 4) Output directory" + (outdir != "" ? ":\n\t" + outdir : "") + @"
+ 5) Split the file
+ B) Go back to the previous menu
+");
+ Console.Write("Enter selection: ");
+ selection = Console.ReadLine();
+ switch (selection)
+ {
+ case "1":
+ Console.Clear();
+ Console.Write("Please enter the file name: ");
+ input = Console.ReadLine();
+ break;
+ case "2":
+ Console.Clear();
+ Console.Write("Please enter the first extension: ");
+ exta = Console.ReadLine();
+ break;
+ case "3":
+ Console.Clear();
+ Console.Write("Please enter the second extension: ");
+ extb = Console.ReadLine();
+ break;
+ case "4":
+ Console.Clear();
+ Console.Write("Please enter the output directory: ");
+ exta = Console.ReadLine();
+ break;
+ case "5":
+ Console.Clear();
+ InitTrimMerge(input, root, rename, forceunzip);
+ Console.Write("\nPress any key to continue...");
+ Console.ReadKey();
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Wrap trimming and merging a single DAT
+ ///
+ /// Input file or folder to be converted
+ /// Root directory to base path lengths on
+ /// True is games should not be renamed
+ /// True if forcepacking="unzip" should be included
+ private static void InitTrimMerge(string input, string root, bool rename, bool force)
+ {
+ // Strip any quotations from the name
+ input = input.Replace("\"", "");
+
+ if (input != "" && (File.Exists(input) || Directory.Exists(input)))
+ {
+ TrimMerge sg = new TrimMerge(input, root, rename, force, logger);
+ sg.Process();
+ return;
+ }
+ }
+
///
/// List sources in the database
///
diff --git a/DATabase/DatSplit.cs b/DATabase/DatSplit.cs
index 10fa8d41..7e33bc37 100644
--- a/DATabase/DatSplit.cs
+++ b/DATabase/DatSplit.cs
@@ -9,9 +9,10 @@ namespace SabreTools
public class DatSplit
{
// Instance variables
- private static string _extA;
- private static string _extB;
- private static string _filename;
+ private string _extA;
+ private string _extB;
+ private string _filename;
+ private string _outdir;
private static Logger _logger;
///
@@ -21,50 +22,15 @@ namespace SabreTools
/// First extension to split on
/// Second extension to split on
/// Logger object for console and file writing
- public DatSplit(string filename, string extA, string extB, Logger logger)
+ public DatSplit(string filename, string extA, string extB, string outdir, Logger logger)
{
_filename = filename.Replace("\"", "");
_extA = (extA.StartsWith(".") ? extA : "." + extA).ToUpperInvariant();
_extB = (extB.StartsWith(".") ? extB : "." + extB).ToUpperInvariant();
+ _outdir = outdir.Replace("\"", "");
_logger = logger;
}
- public static void Main(string[] args)
- {
- Console.Clear();
-
- // Credits take precidence over all
- if ((new List(args)).Contains("--credits"))
- {
- Build.Credits();
- return;
- }
-
- // If we don't have arguments, show help
- if (args.Length == 0 && args.Length != 3)
- {
- Build.Help();
- return;
- }
-
- Logger logger = new Logger(false, "datsplit.log");
- logger.Start();
-
- // Output the title
- Build.Start("DatSplit");
-
- // Set needed variables
- _filename = args[0];
- _extA = (args[1].StartsWith(".") ? args[1] : "." + args[1]).ToUpperInvariant();
- _extB = (args[2].StartsWith(".") ? args[2] : "." + args[2]).ToUpperInvariant();
-
- // Split the DAT
- DatSplit ds = new DatSplit(_filename, _extA, _extB, logger);
- ds.Split();
-
- logger.Close();
- }
-
///
/// Split a DAT based on filtering by 2 extensions
///
@@ -78,6 +44,12 @@ namespace SabreTools
return false;
}
+ // If the output directory doesn't exist, create it
+ if (!Directory.Exists(_outdir))
+ {
+ Directory.CreateDirectory(_outdir);
+ }
+
List romsA = new List();
List romsB = new List();
diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs
index 73e936ee..345216f0 100644
--- a/SabreHelper/Build.cs
+++ b/SabreHelper/Build.cs
@@ -82,6 +82,9 @@ Options:
out= Output directory
-cx, --convert-xml Convert a RV DAT to XML
out= Output directory
+ -es, --ext-split Split a DAT by two file extensions
+ exta= First extension to split by
+ extb= Second extension to split by
-g, --generate Start tool in generate mode
-ga, --generate-all Start tool in generate all mode
system= Comma-separated list of system IDs
@@ -105,11 +108,6 @@ Filenames and directories can't start with a reserved string
unless prefixed by 'input='
");
break;
- case "DatSplit":
- Console.WriteLine(@"DatSplit - Split DAT files by file extension
------------------------------------------
-Usage: DatSplit.exe ");
- break;
case "Headerer":
Console.WriteLine(@"Headerer - Remove and restore rom headers
-----------------------------------------