diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs
index 7cda1f4e..299e0d73 100644
--- a/SabreTools.Helper/Data/Build.cs
+++ b/SabreTools.Helper/Data/Build.cs
@@ -203,6 +203,7 @@ namespace SabreTools.Helper.Data
// Level/SuperDAT Split
helptext.Add(" -ls, --lvl-split Split a SuperDAT or folder by internal path");
helptext.Add(" -out= Output directory");
+ helptext.Add(" -s, --short Use short output names");
// Sort
helptext.Add(" -ss, --sort Sort input files by a set of DATs");
diff --git a/SabreTools.Helper/Dats/DatFile.cs b/SabreTools.Helper/Dats/DatFile.cs
index 4f175b82..af99b616 100644
--- a/SabreTools.Helper/Dats/DatFile.cs
+++ b/SabreTools.Helper/Dats/DatFile.cs
@@ -4647,6 +4647,12 @@ namespace SabreTools.Helper.Dats
// Get the rom that's mapped to this item
Rom source = (Rom)toFromMap[rom];
+ // If we have an empty rom or machine, there was an issue
+ if (source == null || source.Machine == null || source.Machine.Name == null)
+ {
+ continue;
+ }
+
// If the file is in an archive, we need to treat it specially
string machinename = source.Machine.Name.ToLowerInvariant();
if (machinename.EndsWith(".7z")
@@ -5220,9 +5226,10 @@ namespace SabreTools.Helper.Dats
///
/// Name of the directory to write the DATs out to
/// Parent path for replacement
+ /// True if short names should be used, false otherwise
/// Logger object for console and file writing
/// True if split succeeded, false otherwise
- public bool SplitByLevel(string outDir, string basepath, Logger logger)
+ public bool SplitByLevel(string outDir, string basepath, bool shortname, Logger logger)
{
// Sanitize the basepath to be more predictable
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
@@ -5263,7 +5270,11 @@ namespace SabreTools.Helper.Dats
// Now set the new output values
tempDat.FileName = HttpUtility.HtmlDecode(String.IsNullOrEmpty(tempDat.Name)
? FileName
- : tempDat.Name.Replace(Path.DirectorySeparatorChar.ToString(), " - ").Replace(Path.AltDirectorySeparatorChar.ToString(), " - "));
+ : (shortname
+ ? Path.GetFileName(tempDat.Name)
+ : tempDat.Name.Replace(Path.DirectorySeparatorChar.ToString(), " - ").Replace(Path.AltDirectorySeparatorChar.ToString(), " - ")
+ )
+ );
tempDat.Description += " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
tempDat.Name = Name + " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
tempDat.Type = null;
diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST
index ec7186b1..d2125a2b 100644
--- a/SabreTools.Helper/README.1ST
+++ b/SabreTools.Helper/README.1ST
@@ -345,6 +345,10 @@ Options:
-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.
+
+ -s, --short Use short names for outputted DATs
+ Instead of using ClrMamePro-style long names for DATs, use just the name of the
+ folder as the name of the DAT.
-ss, --sort Sort input files by a set of DATs
This feature allows the user to quickly rebuild based on a supplied DAT file(s). By
diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs
index 5fbff22f..fdcd6eef 100644
--- a/SabreTools/Partials/SabreTools_Inits.cs
+++ b/SabreTools/Partials/SabreTools_Inits.cs
@@ -256,7 +256,8 @@ namespace SabreTools
///
/// List of inputs to be used
/// Output directory for the split files
- private static void InitLevelSplit(List inputs, string outDir)
+ /// True if short filenames should be used, false otherwise
+ private static void InitLevelSplit(List inputs, string outDir, bool shortname)
{
// Loop over the input files
foreach (string input in inputs)
@@ -265,7 +266,7 @@ namespace SabreTools
{
DatFile datFile = new DatFile();
datFile.Parse(Path.GetFullPath(input), 0, 0, _logger, softlist: true, keep: true);
- datFile.SplitByLevel(outDir, Path.GetDirectoryName(input), _logger);
+ datFile.SplitByLevel(outDir, Path.GetDirectoryName(input), shortname, _logger);
}
else if (Directory.Exists(input))
{
@@ -273,7 +274,7 @@ namespace SabreTools
{
DatFile datFile = new DatFile();
datFile.Parse(Path.GetFullPath(file), 0, 0, _logger, softlist: true, keep: true);
- datFile.SplitByLevel(outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), _logger);
+ datFile.SplitByLevel(outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), shortname, _logger);
}
}
else
diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs
index c194e9a2..76319226 100644
--- a/SabreTools/SabreTools.cs
+++ b/SabreTools/SabreTools.cs
@@ -91,6 +91,7 @@ namespace SabreTools
romba = false,
showBaddumpColumn = false,
showNodumpColumn = false,
+ shortname = false,
single = false,
softlist = false,
superdat = false,
@@ -377,6 +378,10 @@ namespace SabreTools
case "--romba":
romba = true;
break;
+ case "-s":
+ case "--short":
+ shortname = true;
+ break;
case "-sd":
case "--superdat":
superdat = true;
@@ -990,7 +995,7 @@ namespace SabreTools
// Split a SuperDAT by lowest available level
else if (splitByLevel)
{
- InitLevelSplit(inputs, outDir);
+ InitLevelSplit(inputs, outDir, shortname);
}
// Split a DAT by item type