Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions EliteAPI/Bindings/BindingsUtils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;

namespace EliteAPI.Bindings;

Expand Down Expand Up @@ -180,12 +181,36 @@ public static DirectoryInfo GetBindingsDirectory()
}

private static DirectoryInfo GetOptionsDirectory()
{
// 1) Explicit override – easiest way to point EliteAPI anywhere you want
var envOverride = Environment.GetEnvironmentVariable("ELITE_OPTIONS_DIR");
if (!string.IsNullOrWhiteSpace(envOverride) && Directory.Exists(envOverride))
return new DirectoryInfo(envOverride);

// 2) Linux / macOS – check Proton path first
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
return new DirectoryInfo(Path.Combine(localAppData, "Frontier Developments", "Elite Dangerous", "Options"));
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

// Proton options path:
// ~/.local/share/Steam/steamapps/compatdata/359320/pfx/drive_c/users/steamuser/AppData/Local/Frontier Developments/Elite Dangerous/Options
var protonOptions = Path.Combine(
home,
".local", "share", "Steam", "steamapps", "compatdata", "359320",
"pfx", "drive_c", "users", "steamuser",
"AppData", "Local", "Frontier Developments", "Elite Dangerous", "Options");

if (Directory.Exists(protonOptions))
return new DirectoryInfo(protonOptions);
}

internal static string GetKeyCode(string? key)
// 3) Fallback – original LocalApplicationData behavior
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
return new DirectoryInfo(Path.Combine(localAppData, "Frontier Developments", "Elite Dangerous", "Options"));
}

internal static string GetKeyCode(string key)
{
if (key == null)
return "-1";
Expand Down
55 changes: 45 additions & 10 deletions EliteAPI/Journals/JournalUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,65 @@ public static List<EventPath> ToPaths(string json)

public static DirectoryInfo GetJournalsDirectory()
{
// 1) Explicit override – easiest way to point EliteAPI anywhere you want
var envOverride = Environment.GetEnvironmentVariable("ELITE_JOURNAL_DIR");
if (!string.IsNullOrWhiteSpace(envOverride) && Directory.Exists(envOverride))
return new DirectoryInfo(envOverride);

// 2) Linux / macOS – handle Proton path first
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ||
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
var home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

// Proton install path for Elite:
var protonDir = Path.Combine(
home,
".local", "share", "Steam", "steamapps", "compatdata", "359320",
"pfx", "drive_c", "users", "steamuser",
"Saved Games", "Frontier Developments", "Elite Dangerous");

if (Directory.Exists(protonDir))
return new DirectoryInfo(protonDir);

// Fallback: try native Saved Games layout under $HOME
var savedGames = Path.Combine(
home, "Saved Games", "Frontier Developments", "Elite Dangerous");

if (Directory.Exists(savedGames))
return new DirectoryInfo(savedGames);
}

// 3) Windows – original behavior (simplified but equivalent)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// on windows, use registry
var result = SHGetKnownFolderPath(
new Guid("4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4"),
0,
new IntPtr(0),
IntPtr.Zero,
out var path);

if (result == 0 && path != IntPtr.Zero)
{
var folderPath = Marshal.PtrToStringUni(path);
if (!string.IsNullOrWhiteSpace(folderPath))
return new DirectoryInfo(Path.Combine(folderPath, "Frontier Developments", "Elite Dangerous"));
return new DirectoryInfo(
Path.Combine(folderPath, "Frontier Developments", "Elite Dangerous"));
}
}

// get through userprofile
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
if (!string.IsNullOrWhiteSpace(userProfile))
return new DirectoryInfo(Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous"));
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
if (!string.IsNullOrWhiteSpace(userProfile))
return new DirectoryInfo(
Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous"));

return new DirectoryInfo(
Path.Combine($@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous"));
}

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

public static void PrepareLocalisations(string json)
Expand Down
Loading