windirs

A safe wrapper around SHGetKnownFolderPath

3 releases (stable)

1.0.1 Mar 6, 2021
0.1.0 Mar 6, 2021

#169 in Windows APIs

Download history 331/week @ 2024-07-19 339/week @ 2024-07-26 457/week @ 2024-08-02 422/week @ 2024-08-09 468/week @ 2024-08-16 508/week @ 2024-08-23 335/week @ 2024-08-30 408/week @ 2024-09-06 356/week @ 2024-09-13 210/week @ 2024-09-20 231/week @ 2024-09-27 311/week @ 2024-10-04 302/week @ 2024-10-11 377/week @ 2024-10-18 392/week @ 2024-10-25 276/week @ 2024-11-01

1,379 downloads per month
Used in 7 crates (via pathos)

Apache-2.0 OR MIT

12KB
354 lines

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.

Dependencies

~225KB