diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index cebbaae8..edc95829 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -4726,6 +4726,64 @@ namespace SabreTools.Library.DatFiles
#region Splitting
+ ///
+ /// Split a set of input DATs based on the given information
+ ///
+ /// List of inputs to be used
+ /// Output directory for the split files
+ /// True if files should be written to the source folders, false otherwise
+ /// 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)
+ public void DetermineSplitType(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);
+
+ // Loop over the input files
+ foreach (string file in files)
+ {
+ // Split the input filename
+ string[] splitpath = file.Split('¬');
+
+ // Create and fill the new DAT
+ Parse(splitpath[0], 0, 0);
+
+ // Get the output directory
+ outDir = Utilities.GetOutputPath(outDir, file, inplace, splitpath: true);
+
+ // Split and write the DAT
+ switch (splitType)
+ {
+ case ExternalSplitType.Extension:
+ SplitByExtension(outDir, inplace, exta, extb);
+ break;
+ case ExternalSplitType.Hash:
+ SplitByHash(outDir, inplace);
+ break;
+ case ExternalSplitType.Level:
+ SplitByLevel(outDir, inplace, shortname, basedat);
+ break;
+ case ExternalSplitType.Type:
+ SplitByType(outDir, inplace);
+ break;
+ }
+
+ // Now re-empty the DAT to make room for the next one
+ _datHeader = new DatHeader();
+ ResetDictionary();
+ }
+ }
+
///
/// Split a DAT by input extensions
///
diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs
index 76349116..66e22b64 100644
--- a/SabreTools/SabreTools.Inits.cs
+++ b/SabreTools/SabreTools.Inits.cs
@@ -257,45 +257,8 @@ namespace SabreTools
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);
-
- // 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
- 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;
- }
- }
+ DatFile datfile = new DatFile();
+ datfile.DetermineSplitType(inputs, outDir, inplace, splitType, exta, extb, shortname, basedat);
}
///