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
|
// Level/SuperDAT Split
|
||||||
helptext.Add(" -ls, --lvl-split Split a SuperDAT or folder by internal path");
|
helptext.Add(" -ls, --lvl-split Split a SuperDAT or folder by internal path");
|
||||||
helptext.Add(" -out= Output directory");
|
helptext.Add(" -out= Output directory");
|
||||||
|
helptext.Add(" -s, --short Use short output names");
|
||||||
|
|
||||||
// Sort
|
// Sort
|
||||||
helptext.Add(" -ss, --sort Sort input files by a set of DATs");
|
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
|
// Get the rom that's mapped to this item
|
||||||
Rom source = (Rom)toFromMap[rom];
|
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
|
// If the file is in an archive, we need to treat it specially
|
||||||
string machinename = source.Machine.Name.ToLowerInvariant();
|
string machinename = source.Machine.Name.ToLowerInvariant();
|
||||||
if (machinename.EndsWith(".7z")
|
if (machinename.EndsWith(".7z")
|
||||||
@@ -5220,9 +5226,10 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
/// <param name="outDir">Name of the directory to write the DATs out to</param>
|
||||||
/// <param name="basepath">Parent path for replacement</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>
|
/// <param name="logger">Logger object for console and file writing</param>
|
||||||
/// <returns>True if split succeeded, false otherwise</returns>
|
/// <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
|
// Sanitize the basepath to be more predictable
|
||||||
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar);
|
||||||
@@ -5263,7 +5270,11 @@ namespace SabreTools.Helper.Dats
|
|||||||
// Now set the new output values
|
// Now set the new output values
|
||||||
tempDat.FileName = HttpUtility.HtmlDecode(String.IsNullOrEmpty(tempDat.Name)
|
tempDat.FileName = HttpUtility.HtmlDecode(String.IsNullOrEmpty(tempDat.Name)
|
||||||
? FileName
|
? 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.Description += " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
|
||||||
tempDat.Name = Name + " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
|
tempDat.Name = Name + " (" + tempDat.Name.Replace(Path.DirectorySeparatorChar, '-').Replace(Path.AltDirectorySeparatorChar, '-') + ")";
|
||||||
tempDat.Type = null;
|
tempDat.Type = null;
|
||||||
|
|||||||
@@ -345,6 +345,10 @@ Options:
|
|||||||
-out= Set the name of the output directory
|
-out= Set the name of the output directory
|
||||||
This sets an output folder to be used when the files are created. If a path
|
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.
|
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
|
-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
|
This feature allows the user to quickly rebuild based on a supplied DAT file(s). By
|
||||||
|
|||||||
@@ -256,7 +256,8 @@ namespace SabreTools
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inputs">List of inputs to be used</param>
|
/// <param name="inputs">List of inputs to be used</param>
|
||||||
/// <param name="outDir">Output directory for the split files</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
|
// Loop over the input files
|
||||||
foreach (string input in inputs)
|
foreach (string input in inputs)
|
||||||
@@ -265,7 +266,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
DatFile datFile = new DatFile();
|
DatFile datFile = new DatFile();
|
||||||
datFile.Parse(Path.GetFullPath(input), 0, 0, _logger, softlist: true, keep: true);
|
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))
|
else if (Directory.Exists(input))
|
||||||
{
|
{
|
||||||
@@ -273,7 +274,7 @@ namespace SabreTools
|
|||||||
{
|
{
|
||||||
DatFile datFile = new DatFile();
|
DatFile datFile = new DatFile();
|
||||||
datFile.Parse(Path.GetFullPath(file), 0, 0, _logger, softlist: true, keep: true);
|
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
|
else
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ namespace SabreTools
|
|||||||
romba = false,
|
romba = false,
|
||||||
showBaddumpColumn = false,
|
showBaddumpColumn = false,
|
||||||
showNodumpColumn = false,
|
showNodumpColumn = false,
|
||||||
|
shortname = false,
|
||||||
single = false,
|
single = false,
|
||||||
softlist = false,
|
softlist = false,
|
||||||
superdat = false,
|
superdat = false,
|
||||||
@@ -377,6 +378,10 @@ namespace SabreTools
|
|||||||
case "--romba":
|
case "--romba":
|
||||||
romba = true;
|
romba = true;
|
||||||
break;
|
break;
|
||||||
|
case "-s":
|
||||||
|
case "--short":
|
||||||
|
shortname = true;
|
||||||
|
break;
|
||||||
case "-sd":
|
case "-sd":
|
||||||
case "--superdat":
|
case "--superdat":
|
||||||
superdat = true;
|
superdat = true;
|
||||||
@@ -990,7 +995,7 @@ namespace SabreTools
|
|||||||
// Split a SuperDAT by lowest available level
|
// Split a SuperDAT by lowest available level
|
||||||
else if (splitByLevel)
|
else if (splitByLevel)
|
||||||
{
|
{
|
||||||
InitLevelSplit(inputs, outDir);
|
InitLevelSplit(inputs, outDir, shortname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split a DAT by item type
|
// Split a DAT by item type
|
||||||
|
|||||||
Reference in New Issue
Block a user