| 1 | # xdg-home |
| 2 | |
| 3 | Gets the user's home directory as per [XDG Base Directory Specification][xdg]. |
| 4 | |
| 5 | This is almost the same as [`home`] (and [`dirs`]) crate, except it honors `HOME` environment |
| 6 | variable on the Windows platform as well, which is conformant to the XDG Base Directory |
| 7 | Specification. |
| 8 | |
| 9 | Use it where the XDG Base Directory Specification is applicable, such as in [D-Bus] code. |
| 10 | |
| 11 | ## Example |
| 12 | |
| 13 | ```rust |
| 14 | use xdg_home::home_dir; |
| 15 | |
| 16 | let home = home_dir().unwrap(); |
| 17 | assert!(home.is_absolute()); |
| 18 | assert!(home.exists()); |
| 19 | println!("Home directory: {}", home.display()); |
| 20 | ``` |
| 21 | |
| 22 | [xdg]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html |
| 23 | [`home`]: https://crates.io/crates/home |
| 24 | [`dirs`]: https://crates.io/crates/dirs |
| 25 | [D-Bus]: https://dbus.freedesktop.org/doc/dbus-specification.html |