//! Where things live on disk (same layout as the Python bot): //! assets/ files that ship with the bot //! data/ everything the bot writes at runtime use std::path::PathBuf; use std::sync::OnceLock; fn root() -> &'static PathBuf { static ROOT: OnceLock = OnceLock::new(); ROOT.get_or_init(|| { if let Ok(p) = std::env::var("DEZIO_ROOT") { return PathBuf::from(p); } std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")) }) } /// A path under data/ (parent folders are created on demand). pub fn data(parts: &[&str]) -> PathBuf { let mut p = root().join("data"); p.extend(parts); if let Some(parent) = p.parent() { let _ = std::fs::create_dir_all(parent); } p } pub fn asset(parts: &[&str]) -> PathBuf { let mut p = root().join("assets"); p.extend(parts); p } /// A path under web/ (the dashboard's pages and the Game Boy Activity). pub fn web(parts: &[&str]) -> PathBuf { let mut p = root().join("web"); p.extend(parts); p }