mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Utilities] Add temp dir checking
This commit is contained in:
@@ -2389,6 +2389,32 @@ namespace SabreTools.Library.Tools
|
||||
return outDir;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure the temp directory is a proper format and can be created
|
||||
/// </summary>
|
||||
/// <param name="tempDir">Temp directory to check</param>
|
||||
/// <param name="create">True if the temp directory should be created, false otherwise (default)</param>
|
||||
/// <returns>Full path to the proper temp directory</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the extension from the path, if possible
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user