| Crates.io | cross-xdg |
| lib.rs | cross-xdg |
| version | 2.0.0 |
| created_at | 2025-02-21 21:53:40.33576+00 |
| updated_at | 2025-07-16 14:11:47.084411+00 |
| description | Cross-platform XDG Base Directory Specification implementation |
| homepage | |
| repository | https://github.com/secana/cross-xdg |
| max_upload_size | |
| id | 1564756 |
| size | 39,778 |
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.
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 filesXDG_CACHE_HOME - User-specific non-essential data filesXDG_STATE_HOME - User-specific application state filesXDG_CONFIG_HOME - User-specific configuration filesXDG_RUNTIME_DIR - User-specific runtime filesThe documentation can be found on docs.rs/cross-xdg.
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: