diff --git a/SabreTools.Library/Data/Enums.cs b/SabreTools.Library/Data/Enums.cs
index 84af9b3a..bfd7a471 100644
--- a/SabreTools.Library/Data/Enums.cs
+++ b/SabreTools.Library/Data/Enums.cs
@@ -258,6 +258,18 @@
SHA512,
}
+ ///
+ /// Determines how the DAT will be split on output
+ ///
+ public enum ExternalSplitType
+ {
+ None = 0,
+ Extension,
+ Hash,
+ Level,
+ Type,
+ }
+
///
/// Determines forcemerging tag for DAT output
///
diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs
index a080cc45..76349116 100644
--- a/SabreTools/SabreTools.Inits.cs
+++ b/SabreTools/SabreTools.Inits.cs
@@ -172,66 +172,6 @@ namespace SabreTools
}
}
- ///
- /// Wrap splitting a DAT by 2 extensions
- ///
- /// Input files or folders to be split
- /// First extension to split on
- /// Second extension to split on
- /// Output directory for the split files
- /// True if files should be written to the source folders, false otherwise
- private static void InitExtSplit(List inputs, List exta, List extb, string outDir, bool inplace)
- {
- // Get only files from the inputs
- List files = Utilities.GetOnlyFilesFromInputs(inputs, appendparent: true);
-
- // Loop over the input files
- foreach (string file in files)
- {
- // Split the input filename
- string[] splitpath = file.Split('¬');
-
- // Create and fill the new DAT
- DatFile datFile = new DatFile();
- datFile.Parse(splitpath[0], 0, 0);
-
- // Get the output directory
- outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
-
- // Split and write the DAT
- datFile.SplitByExtension(outDir, inplace, exta, extb);
- }
- }
-
- ///
- /// Wrap splitting a DAT by best available hashes
- ///
- /// List of inputs to be used
- /// Output directory for the split files
- /// True if files should be written to the source folders, false otherwise
- private static void InitHashSplit(List inputs, string outDir, bool inplace)
- {
- // Get only files from the inputs
- List files = Utilities.GetOnlyFilesFromInputs(inputs, appendparent: true);
-
- // Loop over the input files
- foreach (string file in files)
- {
- // Split the input filename
- string[] splitpath = file.Split('¬');
-
- // Create and fill the new DAT
- DatFile datFile = new DatFile();
- datFile.Parse(splitpath[0], 0, 0);
-
- // Get the output directory
- outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
-
- // Split and write the DAT
- datFile.SplitByHash(outDir, inplace);
- }
- }
-
///
/// Wrap replacing headers
///
@@ -248,37 +188,6 @@ namespace SabreTools
}
}
- ///
- /// Wrap splitting a SuperDAT by lowest available level
- ///
- /// List of inputs to be used
- /// Output directory for the split files
- /// True if files should be written to the source folders, false otherwise
- /// True if short filenames should be used, false otherwise
- /// True if original filenames should be used as the base for output filename, false otherwise
- private static void InitLevelSplit(List inputs, string outDir, bool inplace, bool shortname, bool basedat)
- {
- // Get only files from the inputs
- List files = Utilities.GetOnlyFilesFromInputs(inputs, appendparent: true);
-
- // Loop over the input files
- foreach (string file in files)
- {
- // Split the input filename
- string[] splitpath = file.Split('¬');
-
- // Create and fill the new DAT
- DatFile datFile = new DatFile();
- datFile.Parse(splitpath[0], 0, 0);
-
- // Get the output directory
- outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
-
- // Split and write the DAT
- datFile.SplitByLevel(outDir, inplace, shortname, basedat);
- }
- }
-
///
/// Wrap sorting files using an input DAT
///
@@ -335,29 +244,25 @@ namespace SabreTools
}
///
- /// Wrap getting statistics on a DAT or folder of DATs
- ///
- /// List of inputs to be used
- /// Name of the file to output to, blank for default
- /// Output directory for the report files
- /// True to show individual DAT statistics, false otherwise
- /// True if baddumps should be included in output, false otherwise
- /// True if nodumps should be included in output, false otherwise
- /// Set the statistics output format to use
- private static void InitStats(List inputs, string filename, string outDir, bool single, bool baddumpCol, bool nodumpCol,
- StatReportFormat statDatFormat)
- {
- DatFile.OutputStats(inputs, filename, outDir, single, baddumpCol, nodumpCol, statDatFormat);
- }
-
- ///
- /// Wrap splitting a DAT by item type
+ /// Wrap splitting a DAT by any known type
///
/// List of inputs to be used
/// Output directory for the split files
/// True if files should be written to the source folders, false otherwise
- private static void InitTypeSplit(List inputs, string outDir, bool inplace)
+ /// Type of split to perform, if any
+ /// First extension to split on (Extension Split only)
+ /// Second extension to split on (Extension Split only)
+ /// True if short filenames should be used, false otherwise (Level Split only)
+ /// True if original filenames should be used as the base for output filename, false otherwise (Level Split only)
+ private static void InitSplit(List inputs, string outDir, bool inplace, ExternalSplitType splitType,
+ List exta, List extb, bool shortname, bool basedat)
{
+ // If we somehow have the "none" split type, return
+ if (splitType == ExternalSplitType.None)
+ {
+ return;
+ }
+
// Get only files from the inputs
List files = Utilities.GetOnlyFilesFromInputs(inputs, appendparent: true);
@@ -375,10 +280,40 @@ namespace SabreTools
outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
// Split and write the DAT
- datFile.SplitByType(outDir, inplace);
+ switch (splitType)
+ {
+ case ExternalSplitType.Extension:
+ datFile.SplitByExtension(outDir, inplace, exta, extb);
+ break;
+ case ExternalSplitType.Hash:
+ datFile.SplitByHash(outDir, inplace);
+ break;
+ case ExternalSplitType.Level:
+ datFile.SplitByLevel(outDir, inplace, shortname, basedat);
+ break;
+ case ExternalSplitType.Type:
+ datFile.SplitByType(outDir, inplace);
+ break;
+ }
}
}
+ ///
+ /// Wrap getting statistics on a DAT or folder of DATs
+ ///
+ /// List of inputs to be used
+ /// Name of the file to output to, blank for default
+ /// Output directory for the report files
+ /// True to show individual DAT statistics, false otherwise
+ /// True if baddumps should be included in output, false otherwise
+ /// True if nodumps should be included in output, false otherwise
+ /// Set the statistics output format to use
+ private static void InitStats(List inputs, string filename, string outDir, bool single, bool baddumpCol, bool nodumpCol,
+ StatReportFormat statDatFormat)
+ {
+ DatFile.OutputStats(inputs, filename, outDir, single, baddumpCol, nodumpCol, statDatFormat);
+ }
+
///
/// Wrap converting and updating DAT file from any format to any format
///
diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs
index a4c4afaf..396d5a28 100644
--- a/SabreTools/SabreTools.cs
+++ b/SabreTools/SabreTools.cs
@@ -1300,25 +1300,25 @@ namespace SabreTools
// Split a DAT by extension
else if (splitByExt)
{
- InitExtSplit(inputs, exta, extb, outDir, inplace);
+ InitSplit(inputs, outDir, inplace, ExternalSplitType.Extension, exta, extb, shortname, basedat);
}
// Split a DAT by available hashes
else if (splitByHash)
{
- InitHashSplit(inputs, outDir, inplace);
+ InitSplit(inputs, outDir, inplace, ExternalSplitType.Hash, exta, extb, shortname, basedat);
}
// Split a SuperDAT by lowest available level
else if (splitByLevel)
{
- InitLevelSplit(inputs, outDir, inplace, shortname, basedat);
+ InitSplit(inputs, outDir, inplace, ExternalSplitType.Level, exta, extb, shortname, basedat);
}
// Split a DAT by item type
else if (splitByType)
{
- InitTypeSplit(inputs, outDir, inplace);
+ InitSplit(inputs, outDir, inplace, ExternalSplitType.Type, exta, extb, shortname, basedat);
}
// Get statistics on input files