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)
|
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)
|
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
|
// Load the engine version as early as possible so it can be written to exception logs
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
EngineVersion = File.ReadAllText(Platform.ResolvePath(Path.Combine(".", "VERSION"))).Trim();
|
EngineVersion = File.ReadAllText(Path.Combine(Platform.GameDir, "VERSION")).Trim();
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
@@ -324,7 +324,7 @@ namespace OpenRA
|
|||||||
Settings.Game.Platform = p;
|
Settings.Game.Platform = p;
|
||||||
try
|
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 assembly = Assembly.LoadFile(rendererPath);
|
||||||
|
|
||||||
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
|
var platformType = assembly.GetTypes().SingleOrDefault(t => typeof(IPlatform).IsAssignableFrom(t));
|
||||||
@@ -423,7 +423,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
ModData = new ModData(Mods[mod], Mods, true);
|
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())
|
if (!ModData.LoadScreen.BeforeLoad())
|
||||||
return;
|
return;
|
||||||
@@ -539,7 +539,7 @@ namespace OpenRA
|
|||||||
using (new PerfTimer("Renderer.SaveScreenshot"))
|
using (new PerfTimer("Renderer.SaveScreenshot"))
|
||||||
{
|
{
|
||||||
var mod = ModData.Manifest.Metadata;
|
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);
|
Directory.CreateDirectory(directory);
|
||||||
|
|
||||||
var filename = TimestampedFilename(true);
|
var filename = TimestampedFilename(true);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace OpenRA.Network
|
|||||||
{
|
{
|
||||||
var filename = chooseFilename();
|
var filename = chooseFilename();
|
||||||
var mod = Game.ModData.Manifest;
|
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))
|
if (!Directory.Exists(dir))
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
|
|||||||
@@ -203,12 +203,6 @@ namespace OpenRA
|
|||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Replace special character prefixes with full paths.</summary>
|
|
||||||
public static string ResolvePath(params string[] path)
|
|
||||||
{
|
|
||||||
return ResolvePath(Path.Combine(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Replace the full path prefix with the special notation characters ^ or .
|
/// Replace the full path prefix with the special notation characters ^ or .
|
||||||
/// and transforms \ path separators to / on Windows
|
/// and transforms \ path separators to / on Windows
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ namespace OpenRA.Scripting
|
|||||||
PlayerCommands = FilterCommands(world.Map.Rules.Actors["player"], knownPlayerCommands);
|
PlayerCommands = FilterCommands(world.Map.Rules.Actors["player"], knownPlayerCommands);
|
||||||
|
|
||||||
runtime.Globals["GameDir"] = Platform.GameDir;
|
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"];
|
tick = (LuaFunction)runtime.Globals["Tick"];
|
||||||
|
|
||||||
// Register globals
|
// Register globals
|
||||||
|
|||||||
@@ -531,7 +531,7 @@ namespace OpenRA.Server
|
|||||||
|
|
||||||
if (Type == ServerType.Dedicated)
|
if (Type == ServerType.Dedicated)
|
||||||
{
|
{
|
||||||
var motdFile = Platform.ResolvePath(Platform.SupportDirPrefix, "motd.txt");
|
var motdFile = Path.Combine(Platform.SupportDir, "motd.txt");
|
||||||
if (!File.Exists(motdFile))
|
if (!File.Exists(motdFile))
|
||||||
File.WriteAllText(motdFile, "Welcome, have fun and good luck!");
|
File.WriteAllText(motdFile, "Welcome, have fun and good luck!");
|
||||||
|
|
||||||
@@ -930,8 +930,8 @@ namespace OpenRA.Server
|
|||||||
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
|
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
|
||||||
filename = filename.Remove(invalidIndex, 1);
|
filename = filename.Remove(invalidIndex, 1);
|
||||||
|
|
||||||
var baseSavePath = Platform.ResolvePath(
|
var baseSavePath = Path.Combine(
|
||||||
Platform.SupportDirPrefix,
|
Platform.SupportDir,
|
||||||
"Saves",
|
"Saves",
|
||||||
ModData.Manifest.Id,
|
ModData.Manifest.Id,
|
||||||
ModData.Manifest.Metadata.Version);
|
ModData.Manifest.Metadata.Version);
|
||||||
@@ -958,8 +958,8 @@ namespace OpenRA.Server
|
|||||||
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
|
while ((invalidIndex = filename.IndexOfAny(invalidChars)) != -1)
|
||||||
filename = filename.Remove(invalidIndex, 1);
|
filename = filename.Remove(invalidIndex, 1);
|
||||||
|
|
||||||
var savePath = Platform.ResolvePath(
|
var savePath = Path.Combine(
|
||||||
Platform.SupportDirPrefix,
|
Platform.SupportDir,
|
||||||
"Saves",
|
"Saves",
|
||||||
ModData.Manifest.Id,
|
ModData.Manifest.Id,
|
||||||
ModData.Manifest.Metadata.Version,
|
ModData.Manifest.Metadata.Version,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
// Load the renderer assembly so we can check its dependencies
|
// 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>();
|
var missing = new List<string>();
|
||||||
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
|
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 newTemplate = panel.Get<ScrollItemWidget>("NEW_TEMPLATE");
|
||||||
|
|
||||||
var mod = modData.Manifest;
|
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
|
// Avoid filename conflicts when creating new saves
|
||||||
if (isSavePanel)
|
if (isSavePanel)
|
||||||
@@ -304,8 +304,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
void Save(World world)
|
void Save(World world)
|
||||||
{
|
{
|
||||||
var filename = saveTextField.Text + ".orasav";
|
var filename = saveTextField.Text + ".orasav";
|
||||||
var testPath = Platform.ResolvePath(
|
var testPath = Path.Combine(
|
||||||
Platform.SupportDirPrefix,
|
Platform.SupportDir,
|
||||||
"Saves",
|
"Saves",
|
||||||
modData.Manifest.Id,
|
modData.Manifest.Id,
|
||||||
modData.Manifest.Metadata.Version,
|
modData.Manifest.Metadata.Version,
|
||||||
@@ -351,7 +351,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
public static bool IsLoadPanelEnabled(Manifest mod)
|
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))
|
if (!Directory.Exists(baseSavePath))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
{
|
{
|
||||||
if (newsBG != null && Game.Settings.Game.FetchNews)
|
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);
|
var currentNews = ParseNews(cacheFile);
|
||||||
if (currentNews != null)
|
if (currentNews != null)
|
||||||
DisplayNews(currentNews);
|
DisplayNews(currentNews);
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");
|
var template = panel.Get<ScrollItemWidget>("REPLAY_TEMPLATE");
|
||||||
|
|
||||||
var mod = modData.Manifest;
|
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))
|
if (Directory.Exists(dir))
|
||||||
ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template));
|
ThreadPool.QueueUserWorkItem(_ => LoadReplays(dir, template));
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(Platform.ResolvePath("^", "Logs"));
|
Process.Start(Path.Combine(Platform.SupportDir, "Logs"));
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user