use std::path::{Path, PathBuf};
#[derive(Debug, Clone)]
pub struct Paths {
pub root: PathBuf,
}
impl Paths {
#[must_use]
pub fn at(root: impl Into<PathBuf>) -> Self {
Self { root: root.into() }
}
#[must_use]
pub fn home() -> Self {
let root = std::env::var_os("HOME").map_or_else(
|| PathBuf::from(".vibesurfer"),
|h| Path::new(&h).join(".vibesurfer"),
);
Self::at(root)
}
#[must_use]
pub fn socket(&self) -> PathBuf {
self.root.join("daemon.sock")
}
#[must_use]
pub fn pid_file(&self) -> PathBuf {
self.root.join("daemon.pid")
}
#[must_use]
pub fn db(&self) -> PathBuf {
self.root.join("state.db")
}
#[must_use]
pub fn active_session(&self) -> PathBuf {
self.root.join("active-session")
}
#[must_use]
pub fn key_file(&self) -> PathBuf {
self.root.join("key")
}
#[must_use]
pub fn captures(&self) -> PathBuf {
if let Some(p) = std::env::var_os("VS_CAPTURES_DIR") {
return PathBuf::from(p);
}
self.root.join("captures")
}
pub fn ensure_root(&self) -> std::io::Result<()> {
std::fs::create_dir_all(&self.root)
}
}