Cache the support dir path.
This commit is contained in:
@@ -62,35 +62,35 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SupportDir
|
public static string SupportDir { get { return supportDir.Value; } }
|
||||||
|
static Lazy<string> supportDir = Exts.Lazy(GetSupportDir);
|
||||||
|
|
||||||
|
static string GetSupportDir()
|
||||||
{
|
{
|
||||||
get
|
// Use a local directory in the game root if it exists
|
||||||
|
if (Directory.Exists("Support"))
|
||||||
|
return "Support" + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
var dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||||
|
|
||||||
|
switch (CurrentPlatform)
|
||||||
{
|
{
|
||||||
// Use a local directory in the game root if it exists
|
case PlatformType.Windows:
|
||||||
if (Directory.Exists("Support"))
|
dir += Path.DirectorySeparatorChar + "OpenRA";
|
||||||
return "Support" + Path.DirectorySeparatorChar;
|
break;
|
||||||
|
case PlatformType.OSX:
|
||||||
var dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
dir += "/Library/Application Support/OpenRA";
|
||||||
|
break;
|
||||||
switch (CurrentPlatform)
|
case PlatformType.Linux:
|
||||||
{
|
default:
|
||||||
case PlatformType.Windows:
|
dir += "/.openra";
|
||||||
dir += Path.DirectorySeparatorChar + "OpenRA";
|
break;
|
||||||
break;
|
|
||||||
case PlatformType.OSX:
|
|
||||||
dir += "/Library/Application Support/OpenRA";
|
|
||||||
break;
|
|
||||||
case PlatformType.Linux:
|
|
||||||
default:
|
|
||||||
dir += "/.openra";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Directory.Exists(dir))
|
|
||||||
Directory.CreateDirectory(dir);
|
|
||||||
|
|
||||||
return dir + Path.DirectorySeparatorChar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(dir))
|
||||||
|
Directory.CreateDirectory(dir);
|
||||||
|
|
||||||
|
return dir + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } }
|
public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } }
|
||||||
|
|||||||
Reference in New Issue
Block a user