Function zng::env::config

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

Gets a path relative to the user config directory for the app.

  • The config dir can be set by init_config before any env dir is used.
  • In Android returns android_internal("config").
  • In Linux, macOS and Windows if a file in res("config-dir") is found the first non-empty and non-comment (#) line defines the res path.
  • In cfg(debug_assertions) builds returns target/tmp/dev_config/.
  • In all platforms attempts directories::ProjectDirs::config_dir and panic if it fails.
  • If the config dir selected by the previous method contains a "config-dir" file it will be used to redirect to another config dir, you can use this to implement config migration. Redirection only happens once.

The config directory is created if it is missing, checks once on init or first use.