INNER CODE UNIT · Rust
restrict_writes_to
jub0t/Concat · src/crates/concat-api/src/lib.rs:230
pub fn restrict_writes_to(&mut self, roots: Vec<PathBuf>) {
self.roots = roots
.into_iter()
.map(|root| root.canonicalize().unwrap_or(root))
.collect();
}
/// The roots writes are confined to; empty when they are not.
pub fn roots(&self) -> &[PathBuf] {
&self.roots
}
/// `path` as somewhere this API may write, or why not.
fn writable(&self, path: &str) -> Result<(), ApiError> {
if self.roots.is_empty() {
return Ok(());
}
let outside = || {