Merge pull request #12027 from pchote/fix-cwd-crash
Fix crash when launching from a different directory than the game binary.
This commit is contained in:
@@ -39,8 +39,8 @@ namespace OpenRA
|
|||||||
var kernelName = p.StandardOutput.ReadToEnd();
|
var kernelName = p.StandardOutput.ReadToEnd();
|
||||||
if (kernelName.Contains("Darwin"))
|
if (kernelName.Contains("Darwin"))
|
||||||
return PlatformType.OSX;
|
return PlatformType.OSX;
|
||||||
else
|
|
||||||
return PlatformType.Linux;
|
return PlatformType.Linux;
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
@@ -82,7 +82,6 @@ namespace OpenRA
|
|||||||
case PlatformType.OSX:
|
case PlatformType.OSX:
|
||||||
dir += "/Library/Application Support/OpenRA";
|
dir += "/Library/Application Support/OpenRA";
|
||||||
break;
|
break;
|
||||||
case PlatformType.Linux:
|
|
||||||
default:
|
default:
|
||||||
dir += "/.openra";
|
dir += "/.openra";
|
||||||
break;
|
break;
|
||||||
@@ -101,12 +100,15 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
path = path.TrimEnd(new char[] { ' ', '\t' });
|
path = path.TrimEnd(new char[] { ' ', '\t' });
|
||||||
|
|
||||||
// paths starting with ^ are relative to the support dir
|
// Paths starting with ^ are relative to the support dir
|
||||||
if (path.StartsWith("^"))
|
if (path.StartsWith("^", StringComparison.Ordinal))
|
||||||
path = SupportDir + path.Substring(1);
|
path = SupportDir + path.Substring(1);
|
||||||
|
|
||||||
// paths starting with . are relative to the game dir
|
// Paths starting with . are relative to the game dir
|
||||||
if (path.StartsWith("./") || path.StartsWith(".\\"))
|
if (path == ".")
|
||||||
|
return GameDir;
|
||||||
|
|
||||||
|
if (path.StartsWith("./", StringComparison.Ordinal) || path.StartsWith(".\\", StringComparison.Ordinal))
|
||||||
path = GameDir + path.Substring(2);
|
path = GameDir + path.Substring(2);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
@@ -121,10 +123,10 @@ namespace OpenRA
|
|||||||
/// <summary>Replace the full path prefix with the special notation characters ^ or .</summary>
|
/// <summary>Replace the full path prefix with the special notation characters ^ or .</summary>
|
||||||
public static string UnresolvePath(string path)
|
public static string UnresolvePath(string path)
|
||||||
{
|
{
|
||||||
if (path.StartsWith(SupportDir))
|
if (path.StartsWith(SupportDir, StringComparison.Ordinal))
|
||||||
path = "^" + path.Substring(SupportDir.Length);
|
path = "^" + path.Substring(SupportDir.Length);
|
||||||
|
|
||||||
if (path.StartsWith(GameDir))
|
if (path.StartsWith(GameDir, StringComparison.Ordinal))
|
||||||
path = "./" + path.Substring(GameDir.Length);
|
path = "./" + path.Substring(GameDir.Length);
|
||||||
|
|
||||||
return path;
|
return path;
|
||||||
|
|||||||
Reference in New Issue
Block a user