cross-xdg

Crates.iocross-xdg
lib.rscross-xdg
version2.0.0
created_at2025-02-21 21:53:40.33576+00
updated_at2025-07-16 14:11:47.084411+00
descriptionCross-platform XDG Base Directory Specification implementation
homepage
repositoryhttps://github.com/secana/cross-xdg
max_upload_size
id1564756
size39,778
Stefan Hausotte (secana)

documentation

https://docs.rs/cross-xdg

README

cross-xdg

Use the XDG base directory specification on Linux, Windows and Mac.

The XDG base directory specification is a standard for storing user-specific configuration, data, cache and runtime files. It is used by many Linux applications and desktop environments, but is not widely supported on other platforms.

This library provides a cross-platform implementation of the XDG base directory specification. It works on Linux, Windows and Mac, and provides a simple API for accessing the standard directories.

Details

For example, lets take the XDG_CONFIG_HOME directory. The XDG_CONFIG_HOME directory is used to store user-specific configuration files. On Linux, this is usually ~/.config, but it can be overridden by setting the XDG_CONFIG_HOME environment variable. This crate will either return the path from XDG_CONFIG_HOME or the default home directory for the corresponding platform.

  • On Linux: /home/<user>/.config or $XDG_CONFIG_HOME

  • On Windows C:\Users\<user>\.config or $XDG_CONFIG_HOME

  • On Mac: /Users/<user>/.config or $XDG_CONFIG_HOME

All the other XDG directories are implemented in the same way in this crate.

  • XDG_DATA_HOME - User-specific data files
  • XDG_CACHE_HOME - User-specific non-essential data files
  • XDG_STATE_HOME - User-specific application state files
  • XDG_CONFIG_HOME - User-specific configuration files
  • XDG_RUNTIME_DIR - User-specific runtime files

Documentation

The documentation can be found on docs.rs/cross-xdg.

Releated Projects

There are several related projects that provide similar functionality, but do not conform to the XDG base directory specification. Instead they use platform-specific conventions.

XDG conformant, but not cross-platform:

Commit count: 0

cargo fmt