Crate xdg_user

Source
Expand description

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());

Structs§

UserDirs
This crates main and only struct, allows you to access the paths to all the user directories

Enums§

Error
This crates main and only error type

Functions§

desktop
Returns an absolute path to users desktop directory (XDG_DESKTOP_DIR), if found
documents
Returns an absolute path to users documents directory (XDG_DOCUMENTS_DIR), if found
downloads
Returns an absolute path to users downloads directory (XDG_DOWNLOAD_DIR), if found
music
Returns an absolute path to users music directory (XDG_MUSIC_DIR), if found
pictures
Returns an absolute path to users pictures directory (XDG_PICTURES_DIR), if found
public
Returns an absolute path to users public share directory (XDG_PUBLICSHARE_DIR), if found
templates
Returns an absolute path to users templates directory (XDG_TEMPLATES_DIR), if found
videos
Returns an absolute path to users videos directory (XDG_VIDEOS_DIR), if found