Resolve the XDG state base directory. Returns `$XDG_STATE_HOME` if set, otherwise `$HOME/.local/state`.
()
| 35 | /// |
| 36 | /// Returns `$XDG_STATE_HOME` if set, otherwise `$HOME/.local/state`. |
| 37 | pub fn xdg_state_dir() -> Result<PathBuf> { |
| 38 | if let Ok(path) = std::env::var("XDG_STATE_HOME") { |
| 39 | return Ok(PathBuf::from(path)); |
| 40 | } |
| 41 | let home = std::env::var("HOME") |
| 42 | .into_diagnostic() |
| 43 | .wrap_err("HOME is not set")?; |
| 44 | Ok(PathBuf::from(home).join(".local").join("state")) |
| 45 | } |
| 46 | |
| 47 | /// The top-level `OpenShell` state directory: `$XDG_STATE_HOME/openshell/`. |
| 48 | pub fn openshell_state_dir() -> Result<PathBuf> { |
no outgoing calls
no test coverage detected