Skip to main content

default_db_path_from

Function default_db_path_from 

Source
pub fn default_db_path_from(
    xdg_data_home: Option<&str>,
    home: Option<&str>,
    appdata: Option<&str>,
    is_windows: bool,
) -> PathBuf
Expand description

Derive bhtune’s default database location the same way config files are discovered, but under the platform’s data directory rather than its config directory – a database is persistent user data, not settings, per the XDG base directory specification.

  • Windows (is_windows = true): %APPDATA%\bhtune\bhtune.db.
  • Elsewhere: $XDG_DATA_HOME/bhtune/bhtune.db, falling back to $HOME/.local/share/bhtune/bhtune.db.
  • A database location must always resolve to something usable (unlike the config file, whose absence is fine) – if none of the above are available, this falls back further to bhtune.db in the current directory, matching the CLI’s original hardcoded placeholder default.