Dynamically resolve data path
This commit is contained in:
@ -7,12 +7,34 @@ global using static RageCoop.Client.Main;
|
||||
global using Console = GTA.Console;
|
||||
global using static RageCoop.Core.Shared;
|
||||
using System.IO;
|
||||
using System;
|
||||
using SHVDN;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace RageCoop.Client
|
||||
{
|
||||
internal static class Shared
|
||||
{
|
||||
public static string BasePath = "RageCoop";
|
||||
private static string GetBasePath()
|
||||
{
|
||||
FileInfo info;
|
||||
string realScriptDir = Directory.GetParent(Instance.FilePath).FullName;
|
||||
nextTarget:
|
||||
info = new(realScriptDir);
|
||||
if (info.LinkTarget != null)
|
||||
{
|
||||
realScriptDir = info.LinkTarget;
|
||||
goto nextTarget;
|
||||
}
|
||||
if (Path.GetFileName(realScriptDir).ToLower() != "scripts")
|
||||
throw new FileNotFoundException($"Unexpected link target {realScriptDir}");
|
||||
|
||||
var baseDir = Directory.GetParent(realScriptDir).FullName;
|
||||
Logger.Debug($"Base directory is {baseDir}");
|
||||
return baseDir;
|
||||
}
|
||||
|
||||
public static string BasePath = GetBasePath();
|
||||
public static string DataPath = Path.Combine(BasePath, "Data");
|
||||
public static string LogPath = Path.Combine(DataPath, "RageCoop.Client.log");
|
||||
public static string SettingsPath = Path.Combine(DataPath, "Setting.json");
|
||||
|
Reference in New Issue
Block a user