Skip to content

Commit

Permalink
Changed: Use Current Process Path instead of Path from Config
Browse files Browse the repository at this point in the history
Fixes Relative Pathed Applications
  • Loading branch information
Sewer56 committed May 23, 2022
1 parent 8ae0f5e commit 020aaf8
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -9,7 +10,9 @@ namespace Reloaded.Universal.Redirector.Structures;
public class ModRedirectorDictionary : IDisposable
{
public Dictionary<string, string> FileRedirects { get; set; } = new Dictionary<String,String>(StringComparer.OrdinalIgnoreCase);


private static string ProgramFolder = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

/// <summary>
/// Target folder the redirection is pointing towards.
/// </summary>
Expand Down Expand Up @@ -73,11 +76,10 @@ private void SetupFileRedirects()

var redirects = new Dictionary<string, string>(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);
Expand All @@ -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;
}
}

0 comments on commit 020aaf8

Please sign in to comment.