From cdf79d35936cd9dc05e52a6b6d1a48736383be7b Mon Sep 17 00:00:00 2001 From: kalimag Date: Mon, 5 Aug 2024 17:56:10 +0200 Subject: [PATCH] Make external tools path independent of working directory (squashed PR #3987) * Make external tools path independent of working directory * Add `ExternalToolsAbsolutePath` extension * Use absolute path for external tool dependencies as well --- .../config/PathEntryCollectionExtensions.cs | 6 ++++++ src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs b/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs index 8fabb510f3..79e6c069ae 100644 --- a/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs +++ b/src/BizHawk.Client.Common/config/PathEntryCollectionExtensions.cs @@ -180,6 +180,12 @@ namespace BizHawk.Client.Common return collection.AbsolutePathFor(path, null); } + public static string ExternalToolsAbsolutePath(this PathEntryCollection collection) + { + var path = collection[PathEntryCollection.GLOBAL, "External Tools"].Path; + return collection.AbsolutePathFor(path, null); + } + public static string MultiDiskAbsolutePath(this PathEntryCollection collection) { var path = collection.ResolveToolsPath(collection[PathEntryCollection.GLOBAL, "Multi-Disk Bundles"].Path); diff --git a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs index 8a840a8801..ac3203783d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs @@ -88,7 +88,7 @@ namespace BizHawk.Client.EmuHawk DirectoryMonitor.Created -= DirectoryMonitor_Created; DirectoryMonitor.Dispose(); } - var path = _config.PathEntries[PathEntryCollection.GLOBAL, "External Tools"].Path; + var path = _config.PathEntries.ExternalToolsAbsolutePath(); if (Directory.Exists(path)) { DirectoryMonitor = new FileSystemWatcher(path, "*.dll") @@ -153,7 +153,7 @@ namespace BizHawk.Client.EmuHawk { foreach (var depFilename in toolAttribute.LoadAssemblyFiles) { - var depFilePath = $"{_config.PathEntries[PathEntryCollection.GLOBAL, "External Tools"].Path}/{depFilename}"; + var depFilePath = Path.Combine(_config.PathEntries.ExternalToolsAbsolutePath(), depFilename); Console.WriteLine($"preloading assembly {depFilePath} requested by ext. tool {toolAttribute.Name}"); Assembly.LoadFrom(depFilePath); }