Resolve the XDG data base directory. Returns `$XDG_DATA_HOME` if set, otherwise `$HOME/.local/share`.
()
| 53 | /// |
| 54 | /// Returns `$XDG_DATA_HOME` if set, otherwise `$HOME/.local/share`. |
| 55 | pub fn xdg_data_dir() -> Result<PathBuf> { |
| 56 | if let Ok(path) = std::env::var("XDG_DATA_HOME") { |
| 57 | return Ok(PathBuf::from(path)); |
| 58 | } |
| 59 | let home = std::env::var("HOME") |
| 60 | .into_diagnostic() |
| 61 | .wrap_err("HOME is not set")?; |
| 62 | Ok(PathBuf::from(home).join(".local").join("share")) |
| 63 | } |
| 64 | |
| 65 | /// Create a directory (and parents) with owner-only permissions (`0o700`) on |
| 66 | /// Unix. On non-Unix platforms, falls back to default permissions. |
no outgoing calls
no test coverage detected