dirs+x86_64 +linux

The dirs module provides access to common paths and directories used for storing application data. This module is compatible with the XDG base directories specification:

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Index

Functions

fn cache(prog: str) str;
fn config(prog: str) str;
fn data(prog: str) str;
fn runtime() (str | fs::error);
fn state(prog: str) str;

Functions

fn cache[link]

fn cache(prog: str) str;

Returns a directory suitable for cache files. The "prog" parameter should be a descriptive name unique to this program. The return value is statically allocated and will be overwritten on subsequent calls to any function in the dirs module.

fn config[link]

fn config(prog: str) str;

Returns a directory suitable for storing config files. The "prog" parameter should be a descriptive name unique to this program. The return value is statically allocated and will be overwritten on subsequent calls to any function in the dirs module.

fn data[link]

fn data(prog: str) str;

Returns a directory suitable for persistent data files. The "prog" parameter should be a descriptive name unique to this program. The return value is statically allocated and will be overwritten on subsequent calls to any function in the dirs module.

fn runtime[link]

fn runtime() (str | fs::error);

Returns a directory suitable for storing non-essential runtime files and other file objects (such as sockets, named pipes, and so on). Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.

The specification requires the directory to be owned by the current user and not be world-readable. No fallback is implemented in case XDG_RUNTIME_DIR is unset or incorrectly set up.

fn state[link]

fn state(prog: str) str;

Returns a directory suitable for storing program state data. The "prog" parameter should be a descriptive name unique to this program. The return value is statically allocated and will be overwritten on subsequent calls to any function in the dirs module.