parent
8c391584d3
commit
b7e6b5132a
@ -0,0 +1,27 @@
|
||||
use std::fs::{set_permissions, metadata, Permissions};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::error::*;
|
||||
|
||||
pub fn get_perms(path: &PathBuf) -> MkrootResult<Permissions> {
|
||||
match metadata(path) {
|
||||
Ok(meta) => Ok(meta.permissions()),
|
||||
Err(e) => Err(MkrootError::from(format!(
|
||||
"Error retrieving metadata {}: {}",
|
||||
path.display(),
|
||||
e
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_perms(path: &PathBuf, perms: Permissions) -> MkrootResult<()> {
|
||||
if let Err(e) = set_permissions(path, perms) {
|
||||
return Err(MkrootError::from(format!(
|
||||
"Error setting permissions {}: {}",
|
||||
path.display(),
|
||||
e
|
||||
)));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Reference in new issue