diff --git a/OpenRA.Game/Map/MapCache.cs b/OpenRA.Game/Map/MapCache.cs index eb95faaa52..0683936627 100644 --- a/OpenRA.Game/Map/MapCache.cs +++ b/OpenRA.Game/Map/MapCache.cs @@ -72,13 +72,10 @@ namespace OpenRA try { // HACK: If the path is inside the the support directory then we may need to create it - if (Platform.IsPathRelativeToSupportDirectory(name)) - { - // Assume that the path is a directory if there is not an existing file with the same name - var resolved = Platform.ResolvePath(name); - if (!File.Exists(resolved)) - Directory.CreateDirectory(resolved); - } + // Assume that the path is a directory if there is not an existing file with the same name + var resolved = Platform.ResolvePath(name); + if (resolved.StartsWith(Platform.SupportDir) && !File.Exists(resolved)) + Directory.CreateDirectory(resolved); package = modData.ModFiles.OpenPackage(name); } @@ -144,12 +141,9 @@ namespace OpenRA name = name.Substring(1); // Don't try to open the map directory in the support directory if it doesn't exist - if (Platform.IsPathRelativeToSupportDirectory(name)) - { - var resolved = Platform.ResolvePath(name); - if (!Directory.Exists(resolved) || !File.Exists(resolved)) - continue; - } + var resolved = Platform.ResolvePath(name); + if (resolved.StartsWith(Platform.SupportDir) && (!Directory.Exists(resolved) || !File.Exists(resolved))) + continue; using (var package = (IReadWritePackage)modData.ModFiles.OpenPackage(name)) { diff --git a/OpenRA.Game/Platform.cs b/OpenRA.Game/Platform.cs index b8533bd3ac..319be36028 100644 --- a/OpenRA.Game/Platform.cs +++ b/OpenRA.Game/Platform.cs @@ -22,7 +22,6 @@ namespace OpenRA public static class Platform { - public const string SupportDirPrefix = "^"; public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } } public static readonly Guid SessionGUID = Guid.NewGuid(); @@ -190,7 +189,7 @@ namespace OpenRA path = path.TrimEnd(' ', '\t'); // Paths starting with ^ are relative to the support dir - if (IsPathRelativeToSupportDirectory(path)) + if (path.StartsWith("^", StringComparison.Ordinal)) path = SupportDir + path.Substring(1); // Paths starting with . are relative to the game dir @@ -213,7 +212,7 @@ namespace OpenRA // with inconsistent drive letter case var compare = CurrentPlatform == PlatformType.Windows ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; if (path.StartsWith(SupportDir, compare)) - path = SupportDirPrefix + path.Substring(SupportDir.Length); + path = "^" + path.Substring(SupportDir.Length); if (path.StartsWith(GameDir, compare)) path = "./" + path.Substring(GameDir.Length); @@ -223,10 +222,5 @@ namespace OpenRA return path; } - - public static bool IsPathRelativeToSupportDirectory(string path) - { - return path.StartsWith(SupportDirPrefix, StringComparison.Ordinal); - } } }