-
Notifications
You must be signed in to change notification settings - Fork 66
Add XDG_DATA_HOME as default storage location #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
7a84483
833e0d4
90dc331
f9f7007
bab7f55
91997fa
1cb2398
99cbb91
71f12a6
6afbe79
28e1e3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using System.IO; | ||
|
|
||
| using XIVLauncher.Common; | ||
|
|
||
| namespace XIVLauncher.Core; | ||
|
|
||
| public static class XDG | ||
| { | ||
| private static Platform platform; | ||
|
|
||
| static XDG() | ||
| { | ||
| if (Environment.OSVersion.Platform == PlatformID.Win32NT) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. XDG as a concept mostly makes sense on Linux... |
||
| { | ||
| platform = Platform.Win32; | ||
| } | ||
| else if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
| { | ||
| platform = Platform.Linux; | ||
| } | ||
| else if (Environment.OSVersion.Platform == PlatformID.MacOSX) | ||
| { | ||
| platform = Platform.Mac; | ||
| } | ||
| else | ||
| { | ||
| throw new PlatformNotSupportedException("Unsupported platform"); | ||
| } | ||
| } | ||
| public static string? GetStoragePath(string appName, string? overridePath = null) | ||
| { | ||
| if (!string.IsNullOrEmpty(overridePath)) | ||
| { | ||
| return overridePath; | ||
| } | ||
| if (platform == Platform.Win32) | ||
| { | ||
| return null; // Let Storage class handle it. Windows works fine. | ||
| } | ||
| else if (platform == Platform.Linux || platform == Platform.Mac) | ||
| { | ||
| if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appName))) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On macOS
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the documentation I was reading, $HOME/Library/Application Support/{appName} (or just $HOME/Library/{appname})is the closest there is to XDG_DATA_HOME, and this at least doesn't pollute the ~/Library folder directly. I could switch to using environment variables directly, and that would create ~/.local/share/dev.goats.xlcore for Mac users. Not sure if xlcore even compiles for macos, though. |
||
| { | ||
| return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appName); // Use XDG Base Directory spec path if it exists. | ||
| // This is ~/.local/share/xlcore on Linux and ~/Library/Application Support/xlcore on Mac. | ||
| // This can be overridden with the XL_USERDIR environment variable, which will take precedence over both the old path and the XDG path. | ||
| } | ||
| if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), $".{appName}"))) | ||
| { | ||
| return null; // Let Storage class handle it and use the old ~/.xlcore path if it exists, and the XDG_DATA_HOME/xlcore directory does not exist. | ||
| } | ||
| return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), appName); // Use XDG Base Directory spec path for new installs on Linux and Mac. | ||
| } | ||
| else | ||
| { | ||
| throw new PlatformNotSupportedException("Unsupported platform"); | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not packing all that logic into the Storage class, where it makes sense to be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a PR for that: goatcorp/FFXIVQuickLauncher#1867
In the mean time, I'd still like to get this added, since it can take a very long time to get anything linux-related merged into XL.