Remove redundant dir exists checks

This commit is contained in:
YoshiRulz 2022-08-07 10:36:52 +10:00
parent f228b01bdf
commit 10478e23f1
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 14 additions and 43 deletions

View File

@ -1606,11 +1606,9 @@ namespace BizHawk.Client.EmuHawk
}
else
{
ofd.InitialDirectory = Config.PathEntries.AbsolutePathForType(VSystemID.Raw.Libretro, "Cores");
if (!Directory.Exists(ofd.InitialDirectory))
{
Directory.CreateDirectory(ofd.InitialDirectory);
}
var initDir = Config.PathEntries.AbsolutePathForType(VSystemID.Raw.Libretro, "Cores");
Directory.CreateDirectory(initDir);
ofd.InitialDirectory = initDir;
}
ofd.RestoreDirectory = true;

View File

@ -402,11 +402,7 @@ namespace BizHawk.Client.EmuHawk
private void TbbOpenFolder_Click(object sender, EventArgs e)
{
var frmWares = _pathEntries.FirmwareAbsolutePath();
if (!Directory.Exists(frmWares))
{
Directory.CreateDirectory(frmWares);
}
Directory.CreateDirectory(frmWares);
System.Diagnostics.Process.Start(frmWares);
}

View File

@ -239,11 +239,7 @@ namespace BizHawk.Client.EmuHawk
MovieView.Update();
var directory = _config.PathEntries.MovieAbsolutePath();
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
Directory.CreateDirectory(directory);
var dpTodo = new Queue<string>();
var fpTodo = new List<string>();
dpTodo.Enqueue(directory);

View File

@ -185,10 +185,7 @@ namespace BizHawk.Client.EmuHawk
// Create movie folder if it doesn't already exist
try
{
if (!Directory.Exists(movieFolderPath))
{
Directory.CreateDirectory(movieFolderPath);
}
Directory.CreateDirectory(movieFolderPath);
}
catch (Exception movieDirException)
{

View File

@ -785,19 +785,15 @@ namespace BizHawk.Client.EmuHawk
private void OpenSessionMenuItem_Click(object sender, EventArgs e)
{
var initDir = Config!.PathEntries.LuaAbsolutePath();
Directory.CreateDirectory(initDir);
var ofd = new OpenFileDialog
{
InitialDirectory = Config.PathEntries.LuaAbsolutePath(),
InitialDirectory = initDir,
Filter = SessionsFSFilterSet.ToString(),
RestoreDirectory = true,
Multiselect = false
};
if (!Directory.Exists(ofd.InitialDirectory))
{
Directory.CreateDirectory(ofd.InitialDirectory);
}
var result = this.ShowDialogWithTempMute(ofd);
if (result.IsOk() && !string.IsNullOrWhiteSpace(ofd.FileName))
{
@ -871,19 +867,15 @@ namespace BizHawk.Client.EmuHawk
private void OpenScriptMenuItem_Click(object sender, EventArgs e)
{
var initDir = Config!.PathEntries.LuaAbsolutePath();
Directory.CreateDirectory(initDir);
var ofd = new OpenFileDialog
{
InitialDirectory = Config.PathEntries.LuaAbsolutePath(),
InitialDirectory = initDir,
Filter = new FilesystemFilterSet(FilesystemFilter.LuaScripts, FilesystemFilter.TextFiles).ToString(),
RestoreDirectory = true,
Multiselect = true
};
if (!Directory.Exists(ofd.InitialDirectory))
{
Directory.CreateDirectory(ofd.InitialDirectory);
}
var result = this.ShowDialogWithTempMute(ofd);
if (result.IsOk() && ofd.FileNames != null)
{

View File

@ -66,11 +66,7 @@ namespace BizHawk.Client.EmuHawk
}
public FileInfo OpenFileDialog(string currentFile, string path, FilesystemFilterSet filterSet)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
Directory.CreateDirectory(path);
using var ofd = new OpenFileDialog
{
FileName = !string.IsNullOrWhiteSpace(currentFile)
@ -91,11 +87,7 @@ namespace BizHawk.Client.EmuHawk
}
public static FileInfo SaveFileDialog(string currentFile, string path, FilesystemFilterSet filterSet, IDialogParent parent)
{
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
Directory.CreateDirectory(path);
using var sfd = new SaveFileDialog
{
FileName = Path.GetFileName(currentFile),