Fix for some AppDomains that doesn't add trailing DirectorySeparatorChar.
This commit is contained in:
committed by
Paul Chote
parent
c2e36b8eeb
commit
3a6796ac9d
@@ -95,12 +95,24 @@ namespace OpenRA
|
|||||||
return dir + Path.DirectorySeparatorChar;
|
return dir + Path.DirectorySeparatorChar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GameDir { get { return AppDomain.CurrentDomain.BaseDirectory; } }
|
public static string GameDir
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var dir = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
|
|
||||||
|
// Add trailing DirectorySeparator for some buggy AppPool hosts
|
||||||
|
if (!dir.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
|
||||||
|
dir += Path.DirectorySeparatorChar;
|
||||||
|
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Replaces special character prefixes with full paths.</summary>
|
/// <summary>Replaces special character prefixes with full paths.</summary>
|
||||||
public static string ResolvePath(string path)
|
public static string ResolvePath(string path)
|
||||||
{
|
{
|
||||||
path = path.TrimEnd(new char[] { ' ', '\t' });
|
path = path.TrimEnd(' ', '\t');
|
||||||
|
|
||||||
// Paths starting with ^ are relative to the support dir
|
// Paths starting with ^ are relative to the support dir
|
||||||
if (path.StartsWith("^", StringComparison.Ordinal))
|
if (path.StartsWith("^", StringComparison.Ordinal))
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ namespace OpenRA.Test
|
|||||||
Assert.That(Platform.ResolvePath("./testpath"),
|
Assert.That(Platform.ResolvePath("./testpath"),
|
||||||
Is.EqualTo(Path.Combine(gameDir, "testpath")));
|
Is.EqualTo(Path.Combine(gameDir, "testpath")));
|
||||||
|
|
||||||
|
Assert.That(Platform.ResolvePath(Path.Combine(".", "Foo.dll")),
|
||||||
|
Is.EqualTo(Path.Combine(gameDir, "Foo.dll")));
|
||||||
|
|
||||||
Assert.That(Platform.ResolvePath("testpath"),
|
Assert.That(Platform.ResolvePath("testpath"),
|
||||||
Is.EqualTo("testpath"));
|
Is.EqualTo("testpath"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user