windirs

Crates.iowindirs
lib.rswindirs
version1.0.1
sourcesrc
created_at2021-03-06 18:50:10.49158
updated_at2021-03-06 19:54:17.323109
descriptionA safe wrapper around `SHGetKnownFolderPath`.
homepage
repositoryhttps://github.com/bbqsrc/windirs
max_upload_size
id364884
size23,798
Brendan Molloy (bbqsrc)

documentation

README

windirs

Documentation

A safe wrapper around SHGetKnownFolderPath.

Usage

use windirs::{Error, FolderId, get_known_folder};

let local_app_data_path = match get_known_folder(FolderId::LocalAppData) {
    Ok(path) => path,
    Err(err) => match err {
        // Some folder ids point to virtual paths, so, yeah.
        Error::Virtual => panic!(),
        // When no folder is found.
        Error::NotFound => panic!(),
        // Can occur for a variety of reasons, such as this folder id being unknown to this OS.
        Error::InvalidArg(io_error) => panic!(),
        // Any other potential OS error that could happen, but is not defined by the API.
        Error::Other(io_error) => panic!(),
    }
}

let user_home_path = get_known_folder(FolderId::Profile).unwrap();

License

This project is licensed under either of

at your option.

Commit count: 4

cargo fmt