Change default support dir location on Windows and Linux:
Windows now prefers the ApplicationData directory Linux now prefers XDG_CONFIG_HOME Fall back to the previous directory to avoid data loss or duplication.
This commit is contained in:
@@ -99,22 +99,48 @@ namespace OpenRA
|
|||||||
if (Directory.Exists(localSupportDir))
|
if (Directory.Exists(localSupportDir))
|
||||||
return localSupportDir + Path.DirectorySeparatorChar;
|
return localSupportDir + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
var dir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
// The preferred support dir location for Windows and Linux was changed in mid 2019 to match modern platform conventions
|
||||||
|
string preferredSupportDir;
|
||||||
|
string fallbackSupportDir;
|
||||||
switch (CurrentPlatform)
|
switch (CurrentPlatform)
|
||||||
{
|
{
|
||||||
case PlatformType.Windows:
|
case PlatformType.Windows:
|
||||||
dir += Path.DirectorySeparatorChar + "OpenRA";
|
{
|
||||||
break;
|
preferredSupportDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "OpenRA");
|
||||||
case PlatformType.OSX:
|
fallbackSupportDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "OpenRA");
|
||||||
dir += "/Library/Application Support/OpenRA";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
dir += "/.openra";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PlatformType.OSX:
|
||||||
|
{
|
||||||
|
preferredSupportDir = fallbackSupportDir = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.Personal),
|
||||||
|
"Library", "Application Support", "OpenRA");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PlatformType.Linux:
|
||||||
|
{
|
||||||
|
fallbackSupportDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".openra");
|
||||||
|
|
||||||
return dir + Path.DirectorySeparatorChar;
|
var xdgConfigHome = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
|
||||||
|
if (string.IsNullOrEmpty(xdgConfigHome))
|
||||||
|
xdgConfigHome = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".config");
|
||||||
|
|
||||||
|
preferredSupportDir = Path.Combine(xdgConfigHome, "openra");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
preferredSupportDir = fallbackSupportDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".openra");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the fallback directory if it exists and the preferred one does not
|
||||||
|
if (!Directory.Exists(preferredSupportDir) && Directory.Exists(fallbackSupportDir))
|
||||||
|
return fallbackSupportDir + Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
return preferredSupportDir + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user