configurationBaseDirectory

Divines the default configuration file base directory, depending on what platform we're currently running.

On non-macOS Posix it defaults to $XDG_CONFIG_HOME and falls back to ~/.config if no $XDG_CONFIG_HOME environment variable present.

On macOS it defaults to $HOME/Library/Preferences.

On Windows it defaults to %APPDATA%.

@safe
configurationBaseDirectory
()

Return Value

Type: auto

A string path to the default configuration file.

Examples

import std.algorithm.searching : endsWith;

immutable cfgd = configurationBaseDirectory;

version(OSX)
{
    assert(cfgd.endsWith("Library/Preferences"), cfgd);
}
else version(Posix)
{
    import std.process : environment;

    environment["XDG_CONFIG_HOME"] = "/tmp";
    immutable cfgdTmp = configurationBaseDirectory;
    assert((cfgdTmp == "/tmp"), cfgdTmp);

    environment.remove("XDG_CONFIG_HOME");
    immutable cfgdWithout = configurationBaseDirectory;
    assert(cfgdWithout.endsWith("/.config"), cfgdWithout);
}
else version(Windows)
{
    assert(cfgd.endsWith("\\Roaming"), cfgd);
}