Better Global ROM folder logic

This commit is contained in:
adelikat 2014-07-21 23:41:41 +00:00
parent b5f6004674
commit 7d89765568
1 changed files with 22 additions and 1 deletions

View File

@ -212,6 +212,17 @@ namespace BizHawk.Client.Common
return MakeAbsolutePath(Global.Config.PathEntries.LuaPathFragment, null);
}
// Decides if a path is non-empty, not . and not .\
private static bool PathIsSet(string path)
{
if (!string.IsNullOrWhiteSpace(path))
{
return path != "." && path != ".\\";
}
return false;
}
public static string GetRomsPath(string sysID)
{
if (Global.Config.UseRecentForROMs)
@ -219,7 +230,17 @@ namespace BizHawk.Client.Common
return Environment.SpecialFolder.Recent.ToString();
}
var path = Global.Config.PathEntries[sysID, "ROM"] ?? Global.Config.PathEntries["Global", "ROM"] ?? Global.Config.PathEntries[sysID, "Base"];
var path = Global.Config.PathEntries[sysID, "ROM"];
if (path == null || !PathIsSet(path.Path))
{
path = Global.Config.PathEntries["Global", "ROM"];
if (path != null && PathIsSet(path.Path))
{
return MakeAbsolutePath(path.Path, null);
}
}
return MakeAbsolutePath(path.Path, sysID);
}