in below/src/main.rs [322:358]
fn create_log_dir(path: &PathBuf) -> Result<()> {
if path.exists() && !path.is_dir() {
bail!("{} exists and is not a directory", path.to_string_lossy());
}
if !path.is_dir() {
match fs::create_dir_all(path) {
Ok(()) => {}
Err(e) => {
bail!(
"Failed to create dir {}: {}\nTry sudo.",
path.to_string_lossy(),
e
);
}
}
}
let dir = fs::File::open(path).unwrap();
let mut perm = dir.metadata().unwrap().permissions();
if perm.mode() & 0o777 != 0o777 {
perm.set_mode(0o777);
match dir.set_permissions(perm) {
Ok(()) => {}
Err(e) => {
bail!(
"Failed to set permissions on {}: {}",
path.to_string_lossy(),
e
);
}
}
}
Ok(())
}