From 020aaf81d919044c55ffb6877fa0cbe112592fa7 Mon Sep 17 00:00:00 2001 From: Sewer 56 Date: Mon, 23 May 2022 16:27:22 +0100 Subject: [PATCH] Changed: Use Current Process Path instead of Path from Config Fixes Relative Pathed Applications --- .../Structures/ModRedirectorDictionary.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Reloaded.Universal.Redirector/Structures/ModRedirectorDictionary.cs b/Reloaded.Universal.Redirector/Structures/ModRedirectorDictionary.cs index c061555..4256e2e 100644 --- a/Reloaded.Universal.Redirector/Structures/ModRedirectorDictionary.cs +++ b/Reloaded.Universal.Redirector/Structures/ModRedirectorDictionary.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using Reloaded.Mod.Interfaces.Internal; using Reloaded.Universal.Redirector.Utility; @@ -9,7 +10,9 @@ namespace Reloaded.Universal.Redirector.Structures; public class ModRedirectorDictionary : IDisposable { public Dictionary FileRedirects { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - + + private static string ProgramFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); + /// /// Target folder the redirection is pointing towards. /// @@ -73,11 +76,10 @@ private void SetupFileRedirects() var redirects = new Dictionary(StringComparer.OrdinalIgnoreCase); var allModFiles = RelativePaths.GetRelativeFilePaths(RedirectFolder); - var appConfig = Program.ModLoader.GetAppConfig(); foreach (string modFile in allModFiles) { - string applicationFileLocation = GetSourceFolderPath(appConfig, SourceFolder) + modFile; + string applicationFileLocation = ProgramFolder + SourceFolder + modFile; string modFileLocation = RedirectFolder + modFile; applicationFileLocation = Path.GetFullPath(applicationFileLocation); modFileLocation = Path.GetFullPath(modFileLocation); @@ -101,10 +103,4 @@ private void SetupFileWatcher() _watcher.Deleted += (sender, args) => { SetupFileRedirects(); }; _watcher.Renamed += (sender, args) => { SetupFileRedirects(); }; } - - /* Gets path of the source folder to redirect from. */ - private string GetSourceFolderPath(IApplicationConfigV1 config, string sourceFolder) - { - return Path.GetDirectoryName(config.AppLocation) + sourceFolder; - } } \ No newline at end of file