diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs
index 1ad37fba..e7f55306 100644
--- a/SabreTools.Library/DatFiles/DatFile.cs
+++ b/SabreTools.Library/DatFiles/DatFile.cs
@@ -5657,6 +5657,59 @@ namespace SabreTools.Library.DatFiles
#region Static Methods
+ #region Populate DAT from Directory
+
+ ///
+ /// Populate and output DatFiles based on a base DatFile and user inputs
+ ///
+ /// Base DAT that contains special header information to use
+ /// List of inputs to attempt to make DatFiles from
+ /// Hash flag saying what hashes should not be calculated
+ /// True if the date should be omitted from the DAT, false otherwise
+ /// True if archives should be treated as files, false otherwise
+ /// Type of files that should be skipped
+ /// True if blank items should be created for empty folders, false otherwise
+ /// True if dates should be archived for all files, false otherwise
+ /// Name of the directory to create a temp folder in (blank is current directory)
+ /// Output directory to write created DatFiles
+ /// True if files should be copied to the temp directory before hashing, false otherwise
+ /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise
+ /// True if CHDs should be treated like regular files, false otherwise
+ /// True if all DatFiles have been populated successfully, false otherwise
+ public static bool PopulateDatsFromDirs(DatFile basedat, List inputs, Hash omitFromScan, bool bare, bool archivesAsFiles, SkipFileType skipFileType,
+ bool addBlanks, bool addDate, string tempDir, string outDir, bool copyFiles, string headerToCheckAgainst, bool chdsAsFiles)
+ {
+ // Clean the temp directory
+ tempDir = (String.IsNullOrWhiteSpace(tempDir) ? Path.GetTempPath() : tempDir);
+
+ // Set the output variable
+ bool success = true;
+
+ // For each input directory, create a DAT
+ foreach (string path in inputs)
+ {
+ if (Directory.Exists(path) || File.Exists(path))
+ {
+ // Clone the base Dat for information
+ DatFile datdata = new DatFile(basedat);
+
+ string basePath = Path.GetFullPath(path);
+ success &= datdata.PopulateFromDir(basePath, omitFromScan, bare, archivesAsFiles,
+ skipFileType, addBlanks, addDate, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles);
+
+ // If it was a success, write the DAT out
+ if (success)
+ {
+ datdata.WriteToFile(outDir);
+ }
+ }
+ }
+
+ return success;
+ }
+
+ #endregion
+
#region Statistics
///
diff --git a/SabreTools/SabreTools.Inits.cs b/SabreTools/SabreTools.Inits.cs
index f4024fdf..ff80f96a 100644
--- a/SabreTools/SabreTools.Inits.cs
+++ b/SabreTools/SabreTools.Inits.cs
@@ -124,34 +124,15 @@ namespace SabreTools
Type = (superdat ? "SuperDAT" : ""),
};
- // Clean the temp directory
- tempDir = (String.IsNullOrWhiteSpace(tempDir) ? Path.GetTempPath() : tempDir);
+ // Attempt to create all of the DatFiles
+ bool success = DatFile.PopulateDatsFromDirs(basedat, inputs, omitFromScan, removeDateFromAutomaticName, archivesAsFiles,
+ skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, outDir, copyFiles, headerToCheckAgainst, chdsAsFiles);
- // For each input directory, create a DAT
- foreach (string path in inputs)
+ // If it was not successful, show the help
+ if (!success)
{
- if (Directory.Exists(path) || File.Exists(path))
- {
- // Clone the base Dat for information
- DatFile datdata = new DatFile(basedat);
-
- string basePath = Path.GetFullPath(path);
- bool success = datdata.PopulateFromDir(basePath, omitFromScan, removeDateFromAutomaticName, archivesAsFiles,
- skipFileType, addBlankFilesForEmptyFolder, addFileDates, tempDir, copyFiles, headerToCheckAgainst, chdsAsFiles);
-
- // If it was a success, write the DAT out
- if (success)
- {
- datdata.WriteToFile(outDir);
- }
-
- // Otherwise, show the help
- else
- {
- Console.WriteLine();
- _help.OutputIndividualFeature("DATFromDir");
- }
- }
+ Console.WriteLine();
+ _help.OutputIndividualFeature("DATFromDir");
}
}