ACLEditor/src/helper/acl_writer.rs
2025-04-04 08:07:14 +02:00

26 lines
637 B
Rust
Executable File

use std::path::Path;
use anyhow::Result;
use log::trace;
use posix_acl::PosixACL;
use walkdir::WalkDir;
pub fn write_acl_recursive<P: AsRef<Path>>(path: P, acl: PosixACL) -> Result<()> {
for entry in WalkDir::new(path).min_depth(0).follow_links(false) {
let entry = entry?;
let path = entry.path();
trace!("Writing ACL for: {:?} {:?}", path, acl);
match entry.file_type().is_dir() {
true => {
acl.write(&path)?;
acl.write_default(&path)?;
}
false => {
acl.write(&path)?;
}
}
}
Ok(())
}