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
This commit is contained in:
kalimag 2024-08-05 17:56:10 +02:00 committed by GitHub
parent 494fe90bfc
commit cdf79d3593
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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);
}