#path #xdg #directory #folder #filetime #userdir

xdg-user

A library for accessing common user file directories according to xdg-user-dirs

5 releases

0.2.1 May 14, 2020
0.2.0 May 4, 2020
0.1.2 May 4, 2020
0.1.1 May 4, 2020
0.1.0 May 3, 2020

#1205 in Filesystem

Download history 359/week @ 2023-12-17 368/week @ 2023-12-24 270/week @ 2023-12-31 398/week @ 2024-01-07 433/week @ 2024-01-14 454/week @ 2024-01-21 526/week @ 2024-01-28 501/week @ 2024-02-04 591/week @ 2024-02-11 781/week @ 2024-02-18 597/week @ 2024-02-25 515/week @ 2024-03-03 505/week @ 2024-03-10 565/week @ 2024-03-17 723/week @ 2024-03-24 995/week @ 2024-03-31

2,854 downloads per month
Used in tuisic

MIT/Apache

17KB
264 lines

crates.io docs.rs

xdg-user

This simple crate allows you to get paths to well known user directories, using xdg-user-dirss user-dirs.dirs file.

There are two ways of using this crate - with functions in the root of the crate, or with the UserDirs struct. UserDirs will read and parse the config file only once - when you call the UserDirs::new function. Functions in the root will read and parse the config file EVERY TIME you call them - so use them ONLY if you need to get one or two folders one or two times.

Example

println!("Pictures folder: {:?}", xdg_user::pictures()?);
println!("Music folder:    {:?}", xdg_user::music()?);

let dirs = xdg_user::UserDirs::new()?;
println!("Documents folder: {:?}", dirs.documents());
println!("Downloads folder: {:?}", dirs.downloads());

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–8.5MB
~48K SLoC