Remove Platform.UnresolvePath.

This commit is contained in:
Paul Chote
2020-11-20 18:37:04 +00:00
committed by abcdefg30
parent 151cea96e9
commit 72f1f06ebc
3 changed files with 1 additions and 35 deletions

View File

@@ -201,26 +201,5 @@ namespace OpenRA
return path;
}
/// <summary>
/// Replace the full path prefix with the special notation characters ^ or .
/// and transforms \ path separators to / on Windows
/// </summary>
public static string UnresolvePath(string path)
{
// Use a case insensitive comparison on windows to avoid problems
// with inconsistent drive letter case
var compare = CurrentPlatform == PlatformType.Windows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
if (path.StartsWith(SupportDir, compare))
path = "^" + path.Substring(SupportDir.Length);
if (path.StartsWith(GameDir, compare))
path = "./" + path.Substring(GameDir.Length);
if (CurrentPlatform == PlatformType.Windows)
path = path.Replace('\\', '/');
return path;
}
}
}

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
{
modData.ModFiles.TryGetPackageContaining(filename, out var package, out var name);
name = package.Name + "/" + name;
Console.WriteLine("# {0}:", Platform.UnresolvePath(name));
Console.WriteLine("# {0}:", filename);
var yaml = MiniYaml.FromFile(name, false);
FromChromeLayout(ref yaml, null,

View File

@@ -45,18 +45,5 @@ namespace OpenRA.Test
Assert.That(Platform.ResolvePath("testpath"),
Is.EqualTo("testpath"));
}
[TestCase(TestName = "Returns encoded paths")]
public void UnresolvePath()
{
Assert.That(Platform.UnresolvePath(Path.Combine(supportDir, "testpath")),
Is.EqualTo("^testpath"));
Assert.That(Platform.UnresolvePath(Path.Combine(gameDir, "testpath")),
Is.EqualTo("./testpath"));
Assert.That(Platform.UnresolvePath("testpath"),
Is.EqualTo("testpath"));
}
}
}