diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs
index 04596b8e..075a4cf6 100644
--- a/SabreTools.Library/Tools/Utilities.cs
+++ b/SabreTools.Library/Tools/Utilities.cs
@@ -2389,6 +2389,32 @@ namespace SabreTools.Library.Tools
return outDir;
}
+ ///
+ /// Ensure the temp directory is a proper format and can be created
+ ///
+ /// Temp directory to check
+ /// True if the temp directory should be created, false otherwise (default)
+ /// Full path to the proper temp directory
+ public static string EnsureTempDirectory(string tempDir, bool create = false)
+ {
+ // If the output directory is invalid
+ if (string.IsNullOrWhiteSpace(tempDir))
+ {
+ tempDir = Path.GetTempPath();
+ }
+
+ // Get the full path for the output directory
+ tempDir = Path.GetFullPath(tempDir);
+
+ // If we're creating the output folder, do so
+ if (create)
+ {
+ Directory.CreateDirectory(tempDir);
+ }
+
+ return tempDir;
+ }
+
///
/// Get the extension from the path, if possible
///