resourceBaseDirectory

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

On non-macOS Posix it defaults to $XDG_DATA_HOME and falls back to $HOME/.local/share if no $XDG_DATA_HOME environment variable present.

On macOS it defaults to $HOME/Library/Application Support.

On Windows it defaults to %LOCALAPPDATA%.

@safe
resourceBaseDirectory
()

Return Value

Type: auto

A string path to the default resource base directory.

Examples

import std.algorithm.searching : endsWith;

version(OSX)
{
    immutable rbd = resourceBaseDirectory;
    assert(rbd.endsWith("Library/Application Support"), rbd);
}
else version(Posix)
{
    import std.algorithm.searching : startsWith;
    import std.process : environment;

    environment["XDG_DATA_HOME"] = "/tmp";
    string rbd = resourceBaseDirectory;
    assert((rbd == "/tmp"), rbd);

    environment.remove("XDG_DATA_HOME");
    rbd = resourceBaseDirectory;
    assert(rbd.startsWith("/home/") && rbd.endsWith("/.local/share"));
}
else version(Windows)
{
    immutable rbd = resourceBaseDirectory;
    assert(rbd.endsWith("\\Local"), rbd);
}