mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile] Add short name flag for level split
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||
/// <param name="basepath">Parent path for replacement</param>
|
||||
/// <param name="shortname">True if short names should be used, false otherwise</param>
|
||||
/// <param name="logger">Logger object for console and file writing</param>
|
||||
/// <returns>True if split succeeded, false otherwise</returns>
|
||||
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;
|
||||
|
||||
@@ -346,6 +346,10 @@ Options:
|
||||
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
|
||||
default all files will be rebuilt to uncompressed folders in the output directory.
|
||||
|
||||
@@ -256,7 +256,8 @@ namespace SabreTools
|
||||
/// </summary>
|
||||
/// <param name="inputs">List of inputs to be used</param>
|
||||
/// <param name="outDir">Output directory for the split files</param>
|
||||
private static void InitLevelSplit(List<string> inputs, string outDir)
|
||||
/// <param name="shortname">True if short filenames should be used, false otherwise</param>
|
||||
private static void InitLevelSplit(List<string> 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user