[Linux] Use XDG_CONFIG_HOME if it's defined

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is ON
[img] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: [Linux] Use XDG_CONFIG_HOME if it's defined

Re: [Linux] Use XDG_CONFIG_HOME if it's defined

by toxicbits » Fri Mar 23, 2018 5:15 am

Ah, thanks. I didn't know getenv was part of the standard library. Will try that.

Re: [Linux] Use XDG_CONFIG_HOME if it's defined

by Chris » Thu Mar 22, 2018 11:47 pm

The main issues I see are places where you make a call like:

Code: Select all

if (NicePath("$XDG_CONFIG_HOME/").IsEmpty())
Even if XDG_CONFIG_HOME is empty or unset, the returned path would still contain an / which means it'll never be an empty result. Also a number of times you seem to make multiple NicePath calls with XDG_CONFIG_HOME as the base to test if it's set (this isn't performance-sensitive code, but still). A simple getenv should work, testing if it returns NULL or an empty string.

Relatedly, there is also a $XDG_CACHE_HOME in the XDG standard (with a fallback to $HOME/.cache), which might be better to use instead of "$XDG_CONFIG_HOME/zdoom/cache" or "$HOME/.config/zdoom/cache".

Re: [Linux] Use XDG_CONFIG_HOME if it's defined

by toxicbits » Thu Mar 22, 2018 7:20 pm

We use GitHub pull requests for code contributions.
Yeah, I already submitted a pull request for another issue, but didn't in this case since this patch doesn't work (yet). I can clean it up and submit it, though.

I think in most cases, $XDG_CONFIG_HOME is not defined, but the spec states "$XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored. If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.".

Re: [Linux] Use XDG_CONFIG_HOME if it's defined

by _mental_ » Thu Mar 22, 2018 6:36 am

We use GitHub pull requests for code contributions.
While small patches can be accepted, it's much easier to comment and review changes in PR.

For example, this patch cannot be used as is because:
  • It uses C++ IO streams for logging and it's pretty useless anyway in my opinion
  • It alters error reporting in a bad way and two consecutive I_FatalError() calls are simply wrong
Ubuntu versions I tried have no $XDG_CONFIG_HOME defined but only $XDG_CONFIG_DIRS environment variable.

[Linux] Use XDG_CONFIG_HOME if it's defined

by toxicbits » Thu Mar 22, 2018 6:05 am

GZDoom should use the path defined in the environment variable XDG_CONFIG_HOME and if it's not defined, fall back to ~/.config. Cf. the XDG Base Directory Specification: https://standards.freedesktop.org/based ... atest.html

This makes it easier to package. I've tried to fix this myself, but somehow configPath still contains ~/.config in the

Code: Select all

if (mkdir
block even if it should contain the value of the environment variable.
Examples of XDG_CONFIG_HOME usage:

https://github.com/chocolate-doom/choco ... 445e6365d5
https://github.com/Novum/vkQuake/pull/116/files

My patch:
Spoiler:

Top