dirs +linux +x86_64

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(str) str;
fn cachefs(str) *fs::fs;
fn config(str) str;
fn configfs(str) *fs::fs;
fn data(str) str;
fn datafs(str) *fs::fs;
fn runtime() (str | fs::error);
fn state(str) str;
fn statefs(str) *fs::fs;

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 cachefs[link]

fn cachefs(prog: str) *fs::fs;

Returns an fs::fs for cache files.

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 configfs[link]

fn configfs(prog: str) *fs::fs;

Returns an fs::fs for storing config files. The "prog" parameter should be a descriptive name unique to this program.

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 datafs[link]

fn datafs(prog: str) *fs::fs;

Returns an fs::fs for persistent data files. If "prog" is given, a unique path for this program to store data will be returned.

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.

fn statefs[link]

fn statefs(prog: str) *fs::fs;

Returns an fs::fs for storing program state data.