Register temporary directory without specifying any names

This commit is contained in:
Michael Becker 2019-09-06 20:34:18 -04:00
parent a2ca866232
commit 1223941007
2 changed files with 24 additions and 0 deletions

View File

@ -1403,6 +1403,8 @@ namespace UniversalEditor.UserInterface
// overridden with a switch (/basepath:...) ?
mvarBasePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
TemporaryFileManager.RegisterTemporaryDirectory();
BeforeInitialization();
// Initialize the branding for the selected application
@ -1421,6 +1423,8 @@ namespace UniversalEditor.UserInterface
BookmarksManager.Save();
RecentFileManager.Save();
ConfigurationManager.Save();
TemporaryFileManager.UnregisterTemporaryDirectory();
}
public void RestartApplication()
{

View File

@ -43,6 +43,26 @@ namespace UniversalEditor.UserInterface
return filePath;
}
public static bool RegisterTemporaryDirectory()
{
while (true)
{
string pathName = System.IO.Path.GetRandomFileName();
string path = System.IO.Path.Combine(new string[]
{
System.IO.Path.GetTempPath(),
pathName
});
if (!System.IO.Directory.Exists(path))
{
System.IO.Directory.CreateDirectory(path);
mvarTemporaryFilePath = path;
return true;
}
}
}
public static bool RegisterTemporaryDirectory(string prefix, int maxNameLength)
{
if (mvarTemporaryFilePath != null)