You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
657 B
32 lines
657 B
//! Ext for unixes
|
|
use super::*;
|
|
|
|
use std::os::unix::fs::PermissionsExt as UnixPermsExt;
|
|
|
|
use std::borrow::Borrow;
|
|
|
|
pub trait PermissionsExt
|
|
{
|
|
fn unix(&self) -> Permissions;
|
|
fn set_unix(&mut self, perm: impl Borrow<Permissions>);
|
|
fn from_unix(perm: impl Into<Permissions>) -> Self;
|
|
}
|
|
|
|
impl PermissionsExt for std::fs::Permissions
|
|
{
|
|
#[inline] fn unix(&self) -> Permissions
|
|
{
|
|
self.mode().into()
|
|
}
|
|
#[inline] fn set_unix(&mut self, perm: impl Borrow<Permissions>)
|
|
{
|
|
self.set_mode(perm.borrow().mask());
|
|
}
|
|
#[inline] fn from_unix(perm: impl Into<Permissions>) -> Self
|
|
{
|
|
Self::from_mode(perm.into().into())
|
|
}
|
|
}
|
|
|
|
|