Don't use Platform.ResolvePath when constructing hardcoded paths.

This commit is contained in:
Paul Chote
2020-11-20 17:39:06 +00:00
committed by abcdefg30
parent 1dd5b113c7
commit de7a84e8ed
10 changed files with 20 additions and 26 deletions

View File

@@ -262,7 +262,7 @@ namespace OpenRA
public static void InitializeSettings(Arguments args)
{
Settings = new Settings(Platform.ResolvePath(Path.Combine(Platform.SupportDirPrefix, "settings.yaml")), args);
Settings = new Settings(Path.Combine(Platform.SupportDir, "settings.yaml"), args);
}
public static RunStatus InitializeAndRun(string[] args)
@@ -285,7 +285,7 @@ namespace OpenRA
// Load the engine version as early as possible so it can be written to exception logs
try
{
EngineVersion = File.ReadAllText(Platform.ResolvePath(Path.Combine(".", "VERSION"))).Trim();
EngineVersion = File.ReadAllText(Path.Combine(Platform.GameDir, "VERSION")).Trim();
}
catch { }
@@ -324,7 +324,7 @@ namespace OpenRA
Settings.Game.Platform = p;
try
{
var rendererPath = Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms." + p + ".dll"));
var rendererPath = Path.Combine(Platform.GameDir, "OpenRA.Platforms." + p + ".dll");
var assembly = Assembly.LoadFile(rendererPath);
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
@@ -423,7 +423,7 @@ namespace OpenRA
ModData = new ModData(Mods[mod], Mods, true);
LocalPlayerProfile = new LocalPlayerProfile(Platform.ResolvePath(Path.Combine("^", Settings.Game.AuthProfile)), ModData.Manifest.Get<PlayerDatabase>());
LocalPlayerProfile = new LocalPlayerProfile(Path.Combine(Platform.SupportDir, Settings.Game.AuthProfile), ModData.Manifest.Get<PlayerDatabase>());
if (!ModData.LoadScreen.BeforeLoad())
return;
@@ -539,7 +539,7 @@ namespace OpenRA
using (new PerfTimer("Renderer.SaveScreenshot"))
{
var mod = ModData.Manifest.Metadata;
var directory = Platform.ResolvePath(Platform.SupportDirPrefix, "Screenshots", ModData.Manifest.Id, mod.Version);
var directory = Path.Combine(Platform.SupportDir, "Screenshots", ModData.Manifest.Id, mod.Version);
Directory.CreateDirectory(directory);
var filename = TimestampedFilename(true);

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Network
{
var filename = chooseFilename();
var mod = Game.ModData.Manifest;
var dir = Platform.ResolvePath(Platform.SupportDirPrefix, "Replays", mod.Id, mod.Metadata.Version);
var dir = Path.Combine(Platform.SupportDir, "Replays", mod.Id, mod.Metadata.Version);
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);

View File

@@ -203,12 +203,6 @@ namespace OpenRA
return path;
}
/// <summary>Replace special character prefixes with full paths.</summary>
public static string ResolvePath(params string[] path)
{
return ResolvePath(Path.Combine(path));
}
/// <summary>
/// Replace the full path prefix with the special notation characters ^ or .
/// and transforms \ path separators to / on Windows

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Scripting
PlayerCommands = FilterCommands(world.Map.Rules.Actors["player"], knownPlayerCommands);
runtime.Globals["GameDir"] = Platform.GameDir;
runtime.DoBuffer(File.Open(Platform.ResolvePath(".", "lua", "scriptwrapper.lua"), FileMode.Open, FileAccess.Read).ReadAllText(), "scriptwrapper.lua").Dispose();
runtime.DoBuffer(File.Open(Path.Combine(Platform.GameDir, "lua", "scriptwrapper.lua"), FileMode.Open, FileAccess.Read).ReadAllText(), "scriptwrapper.lua").Dispose();
tick = (LuaFunction)runtime.Globals["Tick"];
// Register globals

View File

@@ -531,7 +531,7 @@ namespace OpenRA.Server
if (Type == ServerType.Dedicated)
{
var motdFile = Platform.ResolvePath(Platform.SupportDirPrefix, "motd.txt");
var motdFile = Path.Combine(Platform.SupportDir, "motd.txt");
if (!File.Exists(motdFile))
File.WriteAllText(motdFile, "Welcome, have fun and good luck!");
@@ -930,8 +930,8 @@ namespace OpenRA.Server
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
filename = filename.Remove(invalidIndex, 1);
var baseSavePath = Platform.ResolvePath(
Platform.SupportDirPrefix,
var baseSavePath = Path.Combine(
Platform.SupportDir,
"Saves",
ModData.Manifest.Id,
ModData.Manifest.Metadata.Version);
@@ -958,8 +958,8 @@ namespace OpenRA.Server
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
filename = filename.Remove(invalidIndex, 1);
var savePath = Platform.ResolvePath(
Platform.SupportDirPrefix,
var savePath = Path.Combine(
Platform.SupportDir,
"Saves",
ModData.Manifest.Id,
ModData.Manifest.Metadata.Version,