[SabreTools, DatFile] Use "base" instead of "restore" for level split

This commit is contained in:
Matt Nadareski
2016-10-31 15:37:39 -07:00
parent c65d1cbdf8
commit dd3768cbbb
4 changed files with 15 additions and 10 deletions

View File

@@ -204,7 +204,7 @@ namespace SabreTools.Helper.Data
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"); helptext.Add(" -s, --short Use short output names");
helptext.Add(" -r, --restore Restore original filename to each output DAT"); helptext.Add(" -ba, --base Use source DAT as base name for outputs");
// 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");

View File

@@ -5026,10 +5026,10 @@ namespace SabreTools.Helper.Dats
/// <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="shortname">True if short names should be used, false otherwise</param>
/// <param name="restore">True if original filenames should be used as the base for output filename, false otherwise</param> /// <param name="basedat">True if original filenames should be used as the base for output filename, 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, bool shortname, bool restore, Logger logger) public bool SplitByLevel(string outDir, string basepath, bool shortname, bool basedat, 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);
@@ -5052,7 +5052,7 @@ namespace SabreTools.Helper.Dats
if (tempDat.Name != null && tempDat.Name != Style.GetDirectoryName(key)) if (tempDat.Name != null && tempDat.Name != Style.GetDirectoryName(key))
{ {
// Process and output the DAT // Process and output the DAT
SplitByLevelHelper(tempDat, outDir, shortname, restore, logger); SplitByLevelHelper(tempDat, outDir, shortname, basedat, logger);
// Reset the DAT for the next items // Reset the DAT for the next items
tempDat = (DatFile)CloneHeader(); tempDat = (DatFile)CloneHeader();
@@ -5079,7 +5079,7 @@ namespace SabreTools.Helper.Dats
} }
// Then we write the last DAT out since it would be skipped otherwise // Then we write the last DAT out since it would be skipped otherwise
SplitByLevelHelper(tempDat, outDir, shortname, restore, logger); SplitByLevelHelper(tempDat, outDir, shortname, basedat, logger);
return true; return true;
} }

View File

@@ -257,8 +257,8 @@ namespace SabreTools
/// <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>
/// <param name="shortname">True if short filenames should be used, false otherwise</param> /// <param name="shortname">True if short filenames should be used, false otherwise</param>
/// <param name="restore">True if original filenames should be used as the base for output filename, false otherwise</param> /// <param name="basedat">True if original filenames should be used as the base for output filename, false otherwise</param>
private static void InitLevelSplit(List<string> inputs, string outDir, bool shortname, bool restore) private static void InitLevelSplit(List<string> inputs, string outDir, bool shortname, bool basedat)
{ {
// Loop over the input files // Loop over the input files
foreach (string input in inputs) foreach (string input in inputs)
@@ -267,7 +267,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), shortname, restore, _logger); datFile.SplitByLevel(outDir, Path.GetDirectoryName(input), shortname, basedat, _logger);
} }
else if (Directory.Exists(input)) else if (Directory.Exists(input))
{ {
@@ -275,7 +275,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), shortname, restore, _logger); datFile.SplitByLevel(outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), shortname, basedat, _logger);
} }
} }
else else

View File

@@ -69,6 +69,7 @@ namespace SabreTools
// User flags // User flags
bool addBlankFilesForEmptyFolder = false, bool addBlankFilesForEmptyFolder = false,
addFileDates = false, addFileDates = false,
basedat = false,
cleanGameNames = false, cleanGameNames = false,
copyFiles = false, copyFiles = false,
datPrefix = false, datPrefix = false,
@@ -209,6 +210,10 @@ namespace SabreTools
case "--bare": case "--bare":
removeDateFromAutomaticName = true; removeDateFromAutomaticName = true;
break; break;
case "-ba":
case "--base":
basedat = true;
break;
case "-bc": case "-bc":
case "--baddump-col": case "--baddump-col":
showBaddumpColumn = true; showBaddumpColumn = true;
@@ -994,7 +999,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, shortname, restore); InitLevelSplit(inputs, outDir, shortname, basedat);
} }
// Split a DAT by item type // Split a DAT by item type