Don't use Platform.ResolvePath when constructing hardcoded paths.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
.ToArray();
|
||||
|
||||
// Load the renderer assembly so we can check its dependencies
|
||||
Assembly.LoadFile(Platform.ResolvePath(Path.Combine(".", "OpenRA.Platforms.Default.dll")));
|
||||
Assembly.LoadFile(Path.Combine(Platform.GameDir, "OpenRA.Platforms.Default.dll"));
|
||||
|
||||
var missing = new List<string>();
|
||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var newTemplate = panel.Get<ScrollItemWidget>("NEW_TEMPLATE");
|
||||
|
||||
var mod = modData.Manifest;
|
||||
baseSavePath = Platform.ResolvePath(Platform.SupportDirPrefix, "Saves", mod.Id, mod.Metadata.Version);
|
||||
baseSavePath = Path.Combine(Platform.SupportDir, "Saves", mod.Id, mod.Metadata.Version);
|
||||
|
||||
// Avoid filename conflicts when creating new saves
|
||||
if (isSavePanel)
|
||||
@@ -304,8 +304,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
void Save(World world)
|
||||
{
|
||||
var filename = saveTextField.Text + ".orasav";
|
||||
var testPath = Platform.ResolvePath(
|
||||
Platform.SupportDirPrefix,
|
||||
var testPath = Path.Combine(
|
||||
Platform.SupportDir,
|
||||
"Saves",
|
||||
modData.Manifest.Id,
|
||||
modData.Manifest.Metadata.Version,
|
||||
@@ -351,7 +351,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
public static bool IsLoadPanelEnabled(Manifest mod)
|
||||
{
|
||||
var baseSavePath = Platform.ResolvePath(Platform.SupportDirPrefix, "Saves", mod.Id, mod.Metadata.Version);
|
||||
var baseSavePath = Path.Combine(Platform.SupportDir, "Saves", mod.Id, mod.Metadata.Version);
|
||||
if (!Directory.Exists(baseSavePath))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
if (newsBG != null && Game.Settings.Game.FetchNews)
|
||||
{
|
||||
var cacheFile = Platform.ResolvePath(Platform.SupportDirPrefix, webServices.GameNewsFileName);
|
||||
var cacheFile = Path.Combine(Platform.SupportDir, webServices.GameNewsFileName);
|
||||
var currentNews = ParseNews(cacheFile);
|
||||
if (currentNews != null)
|
||||
DisplayNews(currentNews);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");
|
||||
|
||||
var mod = 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))
|
||||
ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template));
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA
|
||||
{
|
||||
try
|
||||
{
|
||||
Process.Start(Platform.ResolvePath("^", "Logs"));
|
||||
Process.Start(Path.Combine(Platform.SupportDir, "Logs"));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user