use std::path::PathBuf;
use super::is_working_entry;
use crate::paths::layout::{entry, STATE_ROOT_WORKING_DIRS};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ConfigRootAt {
pub path: PathBuf,
pub resolved: PathBuf,
pub own: bool,
}
impl ConfigRootAt {
pub fn shut_to_writes(&self) -> bool {
!self.own
}
pub fn state_dir(&self) -> PathBuf {
self.path.join(entry::STATE)
}
pub fn writable_state_entry(&self, name: &str) -> bool {
!self.shut_to_writes() && is_working_entry(name)
}
pub fn working_entries(&self) -> Vec<PathBuf> {
STATE_ROOT_WORKING_DIRS
.iter()
.filter(|name| self.writable_state_entry(name))
.map(|name| self.resolved.join(entry::STATE).join(name))
.collect()
}
}