Add Platform.SystemSupportDir for shared user data.
This commit is contained in:
@@ -64,15 +64,19 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directory containing user-specific support files (settings, maps, replays, game data, etc).
|
||||
/// The directory will automatically be created if it does not exist when this is queried.
|
||||
/// </summary>
|
||||
public static string SupportDir { get { return supportDir.Value; } }
|
||||
static Lazy<string> supportDir = Exts.Lazy(GetSupportDir);
|
||||
|
||||
static string GetSupportDir()
|
||||
{
|
||||
// Use a local directory in the game root if it exists
|
||||
var supportDir = Path.Combine(GameDir, "Support");
|
||||
if (Directory.Exists(supportDir))
|
||||
return supportDir + Path.DirectorySeparatorChar;
|
||||
// Use a local directory in the game root if it exists (shared with the system support dir)
|
||||
var localSupportDir = Path.Combine(GameDir, "Support");
|
||||
if (Directory.Exists(localSupportDir))
|
||||
return localSupportDir + Path.DirectorySeparatorChar;
|
||||
|
||||
var dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||
|
||||
@@ -95,6 +99,33 @@ namespace OpenRA
|
||||
return dir + Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Directory containing system-wide support files (mod metadata).
|
||||
/// This directory is not guaranteed to exist or be writable.
|
||||
/// Consumers are expected to check the validity of the returned value, and
|
||||
/// fall back to the user support directory if necessary.
|
||||
/// </summary>
|
||||
public static string SystemSupportDir { get { return systemSupportDir.Value; } }
|
||||
static Lazy<string> systemSupportDir = Exts.Lazy(GetSystemSupportDir);
|
||||
|
||||
static string GetSystemSupportDir()
|
||||
{
|
||||
// Use a local directory in the game root if it exists (shared with the system support dir)
|
||||
var localSupportDir = Path.Combine(GameDir, "Support");
|
||||
if (Directory.Exists(localSupportDir))
|
||||
return localSupportDir + Path.DirectorySeparatorChar;
|
||||
|
||||
switch (CurrentPlatform)
|
||||
{
|
||||
case PlatformType.Windows:
|
||||
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "OpenRA") + Path.DirectorySeparatorChar;
|
||||
case PlatformType.OSX:
|
||||
return "/Library/Application Support/OpenRA/";
|
||||
default:
|
||||
return "/var/games/openra/";
|
||||
}
|
||||
}
|
||||
|
||||
public static string GameDir
|
||||
{
|
||||
get
|
||||
|
||||
Reference in New Issue
Block a user