mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, README.1ST] Hook up and document level split
This commit is contained in:
@@ -200,6 +200,10 @@ namespace SabreTools.Helper.Data
|
||||
helptext.Add(" -hs, --hash-split Split a DAT or folder by best-available hashes");
|
||||
helptext.Add(" -out= Output directory");
|
||||
|
||||
// Level/SuperDAT Split
|
||||
helptext.Add(" -ls, --lvl-split Split a SuperDAT or folder by internal path");
|
||||
helptext.Add(" -out= Output directory");
|
||||
|
||||
// Sort
|
||||
helptext.Add(" -ss, --sort Sort input files by a set of DATs");
|
||||
helptext.Add(" -dat= Input DAT to rebuild against");
|
||||
|
||||
@@ -336,9 +336,15 @@ 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.
|
||||
|
||||
-input= Set an input string
|
||||
This should only be used if one of the inputs starts with a flag or another already
|
||||
defined input.
|
||||
-ls, --lvl-split Split a SuperDAT or folder by lowest available level
|
||||
For a DAT, or set of DATs, allow for splitting based on the lowest available level
|
||||
of game name. That is, if a game name is top/mid/last, then it will create
|
||||
an output DAT for the parent directory "mid" in a folder called "top" with a game
|
||||
called "last".
|
||||
|
||||
-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.
|
||||
|
||||
-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
|
||||
|
||||
@@ -244,6 +244,41 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrap splitting a SuperDAT by lowest available level
|
||||
/// </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)
|
||||
{
|
||||
// Loop over the input files
|
||||
foreach (string input in inputs)
|
||||
{
|
||||
if (File.Exists(input))
|
||||
{
|
||||
DatFile datFile = new DatFile();
|
||||
datFile.Parse(Path.GetFullPath(input), 0, 0, _logger, softlist: true);
|
||||
datFile.SplitByLevel(outDir, Path.GetDirectoryName(input), _logger);
|
||||
}
|
||||
else if (Directory.Exists(input))
|
||||
{
|
||||
foreach (string file in Directory.EnumerateFiles(input, "*", SearchOption.AllDirectories))
|
||||
{
|
||||
DatFile datFile = new DatFile();
|
||||
datFile.Parse(Path.GetFullPath(file), 0, 0, _logger, softlist: true);
|
||||
datFile.SplitByLevel(outDir, (input.EndsWith(Path.DirectorySeparatorChar.ToString()) ? input : input + Path.DirectorySeparatorChar), _logger);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Error(input + " is not a valid file or folder!");
|
||||
Console.WriteLine();
|
||||
Build.Help("SabreTools");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Wrap sorting files using an input DAT
|
||||
/// </summary>
|
||||
|
||||
@@ -56,6 +56,7 @@ namespace SabreTools
|
||||
sort = false, // SimpleSort
|
||||
splitByExt = false,
|
||||
splitByHash = false,
|
||||
splitByLevel = false,
|
||||
splitByType = false,
|
||||
stats = false,
|
||||
update = false,
|
||||
@@ -169,6 +170,10 @@ namespace SabreTools
|
||||
case "--hash-split":
|
||||
splitByHash = true;
|
||||
break;
|
||||
case "-ls":
|
||||
case "--lvl-split":
|
||||
splitByLevel = true;
|
||||
break;
|
||||
case "-ss":
|
||||
case "--sort":
|
||||
sort = true;
|
||||
@@ -903,7 +908,7 @@ namespace SabreTools
|
||||
}
|
||||
|
||||
// If more than one switch is enabled, show the help screen
|
||||
if (!(datFromDir ^ headerer ^ sort ^ splitByExt ^ splitByHash ^ splitByType ^ stats ^ update ^ verify))
|
||||
if (!(datFromDir ^ headerer ^ sort ^ splitByExt ^ splitByHash ^ splitByLevel ^ splitByType ^ stats ^ update ^ verify))
|
||||
{
|
||||
_logger.Error("Only one feature switch is allowed at a time");
|
||||
Build.Help("SabreTools");
|
||||
@@ -913,7 +918,7 @@ namespace SabreTools
|
||||
|
||||
// If a switch that requires a filename is set and no file is, show the help screen
|
||||
if (inputs.Count == 0
|
||||
&& (datFromDir || headerer || splitByExt || splitByHash || splitByType || stats || update))
|
||||
&& (datFromDir || headerer || splitByExt || splitByHash || splitByLevel || splitByType || stats || update))
|
||||
{
|
||||
_logger.Error("This feature requires at least one input");
|
||||
Build.Help("SabreTools");
|
||||
@@ -977,6 +982,12 @@ namespace SabreTools
|
||||
InitHashSplit(inputs, outDir);
|
||||
}
|
||||
|
||||
// Split a SuperDAT by lowest available level
|
||||
else if (splitByLevel)
|
||||
{
|
||||
InitLevelSplit(inputs, outDir);
|
||||
}
|
||||
|
||||
// Split a DAT by item type
|
||||
else if (splitByType)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user