17 lines
400 B
Rust
17 lines
400 B
Rust
use std::io::{ErrorKind, Result};
|
|
|
|
use nix::unistd::{Gid, Uid};
|
|
|
|
pub fn create_dir_owned(path: &str, uid: Uid, gid: Gid) -> Result<()> {
|
|
std::fs::create_dir(path)?;
|
|
nix::unistd::chown(path, Some(uid), Some(gid))?;
|
|
Ok(())
|
|
}
|
|
|
|
pub fn ignore_already_exists(r: Result<()>) -> Result<()> {
|
|
match r {
|
|
Err(e) if e.kind() == ErrorKind::AlreadyExists => Ok(()),
|
|
_ => r,
|
|
}
|
|
}
|