zng::env

Function cache

source
pub fn cache(relative_path: impl AsRef<Path>) -> PathBuf
Expand description

Gets a path relative to the cache directory for the app.

  • The cache dir can be set by init_cache before any env dir is used.
  • In Android returns android_internal("cache").
  • In Linux, macOS and Windows if a file config("cache-dir") is found the first non-empty and non-comment (#) line defines the res path.
  • In cfg(debug_assertions) builds returns target/tmp/dev_cache/.
  • In all platforms attempts directories::ProjectDirs::cache_dir and panic if it fails.

The cache dir is created if it is missing, checks once on init or first use.