-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use FHS/XDG paths for UserDefaults on Linux & BSD-y OSes #1399
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
Use FHS/XDG paths for UserDefaults on Linux & BSD-y OSes #1399
Conversation
@swift-ci Please test. |
@@ -1198,7 +1198,7 @@ static CFStringRef _CFXDGCreateHome(void) { | |||
} | |||
|
|||
/// a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME. | |||
CF_SWIFT_EXPORT |
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.
This should still only be exported on non-Darwin platforms. We may need another version of this CF_EXPORT
macro.
|
||
#include <assert.h> | ||
|
||
CONST_STRING_DECL(_kCFKnownLocationUserAny, " == _kCFKnownLocationUserAny"); |
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.
Hm, the ==
at the start is something unusual. In most cases the string is equal to the key name.
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.
Yeah — the idea here was to make sure it couldn't be a valid username. Since we're switching to an enum, this problem goes away.
- Current: $HOME/Library/Preferences | ||
*/ | ||
|
||
if (user == _kCFKnownLocationUserAny) { |
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.
If we're just going to do an ==
check, perhaps we should just declare an enum?
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.
Yeah, that makes sense. It'll be the enum plus a NULLable username string argument.
See CFKnownLocations.c for a summary of what paths are returned. | ||
*/ | ||
|
||
extern CFURLRef _Nullable _CFKnownLocationCreatePreferencesURLForUser(CFKnownLocationUser user); |
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.
We'll need to make sure this is only exported on non-Darwin platforms.
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.
Ok!
@@ -327,8 +327,6 @@ CF_EXPORT _Nullable CFErrorRef CFReadStreamCopyError(CFReadStreamRef stream); | |||
|
|||
CF_EXPORT _Nullable CFErrorRef CFWriteStreamCopyError(CFWriteStreamRef stream); | |||
|
|||
CF_SWIFT_EXPORT Boolean _CFBundleSupportsFHSBundles(void); |
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.
This removal is a merge issue and incorrect.
@swift-ci Please test. |
I'm going to have a proposal for CF_SWIFT_EXPORT as a separate patch, and then rebase this one. |
Out of curiosity, why |
|
@swift-ci Please test. |
@swift-ci Please test and merge. |
On FHS/XDG systems, the paths for UserDefaults are now:
/usr/local/etc
for AnyUser preferences (replaces/Library/Preferences
)$XDG_CONFIG_DIR
for CurrentUser preferences (replaces$HOME/Library/Preferences
)(
$XDG_CONFIG_DIR
is typically, and defaults to,$HOME/.config/
.)