use crate::Result; use std::path::PathBuf; /* The spec does not suggest a default for this one, merely saying that * applications should fall back to something else. So, we return an Option to * allow our caller to worry about that. */ pub fn xdg_runtime_directory() -> Result> { if let Ok(mut path) = std::env::var("XDG_RUNTIME_DIR") { /* As nice as it would be to use a portable interface for this, Rust * doesn't have a stable one yet. In fact, we barely have visibility into * it at all once we convert to a path. * * Oh well. Fuck Microsoft anyway. */ if !path.ends_with("/") { path.push_str("/"); } Ok(Some(PathBuf::from(path))) } else { Ok(None) } }