Skip to main content

platform_dir_with

Function platform_dir_with 

Source
pub fn platform_dir_with(
    app_id: &str,
    env: impl Fn(&str) -> Option<String>,
) -> Option<PathBuf>
Expand description

The cache directory for an application, read from the environment env gives (see the module); none when the variables it needs are missing.

let dir = egui_pop_tokens::cache::platform_dir_with("demo", |name| match name {
    "XDG_CACHE_HOME" => Some("/cache".into()),
    _ => None,
});
if cfg!(all(unix, not(target_os = "macos"))) {
    assert_eq!(dir, Some("/cache/demo/egui-pop".into()));
}