From 925e3346cee274bc799c86ac6a7ed91c02618d07 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 21 Nov 2025 16:38:59 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20journal=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- EliteAPI/Journals/JournalUtils.cs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 EliteAPI/Journals/JournalUtils.cs diff --git a/EliteAPI/Journals/JournalUtils.cs b/EliteAPI/Journals/JournalUtils.cs new file mode 100644 index 00000000..5bfd41ea --- /dev/null +++ b/EliteAPI/Journals/JournalUtils.cs @@ -0,0 +1,38 @@ +using System.Runtime.InteropServices; + +namespace EliteAPI.Journals; + +public static class JournalUtils +{ + public static DirectoryInfo GetJournalsDirectory() + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + // on windows, use registry + var result = SHGetKnownFolderPath( + new Guid("4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4"), + 0, + new IntPtr(0), + 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")); + } + } + + // get through userprofile + var userProfile = Environment.GetEnvironmentVariable("USERPROFILE"); + if (!string.IsNullOrWhiteSpace(userProfile)) + return new DirectoryInfo(Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous")); + + // last resort, hardcoded with C:\ drive, hopefully we'll neve reach this.. + return new DirectoryInfo(Path.Combine($@"C:\Users\{Environment.UserName}\Saved Games\Frontier Developments\Elite Dangerous")); + } + + [DllImport("Shell32.dll")] + private static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, + IntPtr hToken, out IntPtr path); +} From ed68c3c3f7767813941a7dd0c4434635ed06922a Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 21 Nov 2025 17:56:54 +0100 Subject: [PATCH 2/2] Update EliteAPI/Journals/JournalUtils.cs --- EliteAPI/Journals/JournalUtils.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EliteAPI/Journals/JournalUtils.cs b/EliteAPI/Journals/JournalUtils.cs index 5bfd41ea..c7a7796a 100644 --- a/EliteAPI/Journals/JournalUtils.cs +++ b/EliteAPI/Journals/JournalUtils.cs @@ -28,7 +28,7 @@ public static DirectoryInfo GetJournalsDirectory() if (!string.IsNullOrWhiteSpace(userProfile)) return new DirectoryInfo(Path.Combine(userProfile, "Saved Games", "Frontier Developments", "Elite Dangerous")); - // last resort, hardcoded with C:\ drive, hopefully we'll neve reach this.. + // 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")); }