Let's say I'm writing a program, and I want it to follow the XDG Base Directory Specification for where it puts its files (app foo
uses $XDG_CONFIG_HOME/foo
as the directory for configuration files if XDG_CONFIG_HOME
is set and non-blank, or ~/.config/foo
, or fails with an error if the home directory can't even be resolved).
Is there a correct/specified behavior for the situation where for example XDG_CONFIG_HOME
is set and non-blank, but that directory doesn't exist? Or if there is no such variable, and ~/.config
doesn't exist? Is it expected that my program attempt to create it? Or is the non-existance of that directory considered an error on the environment's/system's part, and my program should avoid doing anything about it (just bail with an error)?
Note: I'm not asking if I should create ~/.config/foo
- obviously that's a yes; I'm asking if I should create ~/.config
itself, if it doesn't exist.
(To be more pedantic: obviously some program should create them - the question is whether it's solely the system's/desktop's/user's job to do so, or if any program should try creating the relevant directories if they don't exist?)
I've tried reading the XDG Base Directory Specification, which says that when attempting to write its files, the program may create the requisite directory, but it's unclear if this is referring to just the application's specific/"personal" sub-directory in the XDG base directories, or if this is meant for the XDG base directories themselves.
P.S. Usually I have a good idea of what tags to use, but here I'm really uncertain: please edit this post or suggest improvements to give it proper tags.