Skip to main content

Crate xdge

Crate xdge 

Source
Expand description

§xdge

A complete, zero-dependency implementation of the XDG Base Directory Specification v0.8 for Linux and Unix systems.

§Quick Start

use xdge::XdgDirs;

let xdg = XdgDirs::new();

// Where to write user config
println!("{}", xdg.config_home().display());   // e.g. /home/alice/.config

// Where to write user data
println!("{}", xdg.data_home().display());     // e.g. /home/alice/.local/share

// Search all config dirs for "myapp/settings.toml"
if let Some(path) = xdg.find_config_file("myapp/settings.toml") {
    println!("Found config at {}", path.display());
}

§XDG Variables Implemented

VariableDefaultMethod
$XDG_DATA_HOME$HOME/.local/shareXdgDirs::data_home
$XDG_CONFIG_HOME$HOME/.configXdgDirs::config_home
$XDG_STATE_HOME$HOME/.local/stateXdgDirs::state_home
$XDG_CACHE_HOME$HOME/.cacheXdgDirs::cache_home
$XDG_RUNTIME_DIR(none — warn if unset)XdgDirs::runtime_dir
$XDG_DATA_DIRS/usr/local/share:/usr/shareXdgDirs::data_dirs
$XDG_CONFIG_DIRS/etc/xdgXdgDirs::config_dirs
(user bin)$HOME/.local/binXdgDirs::user_bin_dir

Structs§

XdgDirs
Resolved XDG Base Directory paths.

Enums§

XdgError
Errors that can be returned by directory-creation helpers.