Skip to content

Commit fab1a55

Browse files
authored
Merge pull request #432 from TooterTutor/dev
2 parents e37e6f2 + a76915a commit fab1a55

File tree

2 files changed

+73
-13
lines changed

2 files changed

+73
-13
lines changed

EliteAPI/Bindings/BindingsUtils.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Runtime.InteropServices;
45

56
namespace EliteAPI.Bindings;
67

@@ -180,12 +181,36 @@ public static DirectoryInfo GetBindingsDirectory()
180181
}
181182

182183
private static DirectoryInfo GetOptionsDirectory()
184+
{
185+
// 1) Explicit override – easiest way to point EliteAPI anywhere you want
186+
var envOverride = Environment.GetEnvironmentVariable("ELITE_OPTIONS_DIR");
187+
if (!string.IsNullOrWhiteSpace(envOverride) && Directory.Exists(envOverride))
188+
return new DirectoryInfo(envOverride);
189+
190+
// 2) Linux / macOS – check Proton path first
191+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
192+
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
183193
{
184-
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
185-
return new DirectoryInfo(Path.Combine(localAppData, "Frontier Developments", "Elite Dangerous", "Options"));
194+
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
195+
196+
// Proton options path:
197+
// ~/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/AppData/Local/Frontier Developments/Elite Dangerous/Options
198+
var protonOptions = Path.Combine(
199+
home,
200+
".local", "share", "Steam", "steamapps", "compatdata", "359320",
201+
"pfx", "drive_c", "users", "steamuser",
202+
"AppData", "Local", "Frontier Developments", "Elite Dangerous", "Options");
203+
204+
if (Directory.Exists(protonOptions))
205+
return new DirectoryInfo(protonOptions);
186206
}
187207

188-
internal static string GetKeyCode(string? key)
208+
// 3) Fallback – original LocalApplicationData behavior
209+
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
210+
return new DirectoryInfo(Path.Combine(localAppData, "Frontier Developments", "Elite Dangerous", "Options"));
211+
}
212+
213+
internal static string GetKeyCode(string key)
189214
{
190215
if (key == null)
191216
return "-1";

EliteAPI/Journals/JournalUtils.cs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,65 @@ public static List<EventPath> ToPaths(string json)
5656

5757
public static DirectoryInfo GetJournalsDirectory()
5858
{
59+
// 1) Explicit override – easiest way to point EliteAPI anywhere you want
60+
var envOverride = Environment.GetEnvironmentVariable("ELITE_JOURNAL_DIR");
61+
if (!string.IsNullOrWhiteSpace(envOverride) && Directory.Exists(envOverride))
62+
return new DirectoryInfo(envOverride);
63+
64+
// 2) Linux / macOS – handle Proton path first
65+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
66+
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
67+
{
68+
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
69+
70+
// Proton install path for Elite:
71+
var protonDir = Path.Combine(
72+
home,
73+
".local", "share", "Steam", "steamapps", "compatdata", "359320",
74+
"pfx", "drive_c", "users", "steamuser",
75+
"Saved Games", "Frontier Developments", "Elite Dangerous");
76+
77+
if (Directory.Exists(protonDir))
78+
return new DirectoryInfo(protonDir);
79+
80+
// Fallback: try native Saved Games layout under $HOME
81+
var savedGames = Path.Combine(
82+
home, "Saved Games", "Frontier Developments", "Elite Dangerous");
83+
84+
if (Directory.Exists(savedGames))
85+
return new DirectoryInfo(savedGames);
86+
}
87+
88+
// 3) Windows – original behavior (simplified but equivalent)
5989
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
6090
{
61-
// on windows, use registry
6291
var result = SHGetKnownFolderPath(
6392
new Guid("4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4"),
6493
0,
65-
new IntPtr(0),
94+
IntPtr.Zero,
6695
out var path);
6796

6897
if (result == 0 && path != IntPtr.Zero)
6998
{
7099
var folderPath = Marshal.PtrToStringUni(path);
71100
if (!string.IsNullOrWhiteSpace(folderPath))
72-
return new DirectoryInfo(Path.Combine(folderPath, "Frontier Developments", "Elite Dangerous"));
101+
return new DirectoryInfo(
102+
Path.Combine(folderPath, "Frontier Developments", "Elite Dangerous"));
73103
}
74-
}
75104

76-
// get through userprofile
77-
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
78-
if (!string.IsNullOrWhiteSpace(userProfile))
79-
return new DirectoryInfo(Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous"));
105+
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
106+
if (!string.IsNullOrWhiteSpace(userProfile))
107+
return new DirectoryInfo(
108+
Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous"));
109+
110+
return new DirectoryInfo(
111+
Path.Combine($@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous"));
112+
}
80113

81-
// last resort, hardcoded with C:\ drive, hopefully we'll never reach this..
82-
return new DirectoryInfo(Path.Combine($@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous"));
114+
// 4) Unknown OS – last resort
115+
var genericHome = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
116+
return new DirectoryInfo(
117+
Path.Combine(genericHome, "Saved Games", "Frontier Developments", "Elite Dangerous"));
83118
}
84119

85120
public static void PrepareLocalisations(string json)

0 commit comments

Comments
 (0)