-
Notifications
You must be signed in to change notification settings - Fork 46
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
Support modern locations for configuration files for Unix (XDG_CONFIG_HOME and ~/.config/) #41
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -1903,6 +1903,18 @@ static int FS_ChooseUserDir(userdirmode_t userdirmode, char *userdir, size_t use | |
if(homedir) | ||
{ | ||
dpsnprintf(userdir, userdirsize, "%s/.%s/", homedir, gameuserdirname); | ||
#if defined(__unix__) || defined(__unix) | ||
// Check for darkplaces config paths in this order: ~/.darkplaces, XDG_CONFIG_HOME/darkplaces, ~/.config/darkplaces. | ||
if(access(userdir, F_OK) != 0) | ||
{ | ||
// Check if XDG_CONFIG_HOME exists, test if absolute path. | ||
const char *xdgconfdir = getenv("XDG_CONFIG_HOME"); | ||
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. Note that Any chance that can be fixed first? 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. Failing that, I guess |
||
if(xdgconfdir && xdgconfdir[0] == '/') | ||
dpsnprintf(userdir, userdirsize, "%s/%s/", xdgconfdir, gameuserdirname); | ||
else | ||
dpsnprintf(userdir, userdirsize, "%s/.config/%s/", homedir, gameuserdirname); | ||
} | ||
#endif | ||
break; | ||
} | ||
return -1; | ||
|
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 encodes a preference order. It prefers ~/.darkplaces if it exists, but creates ~/.config/darkplaces if nothing exists. Please explain this in the comment.