Add comments clarifying behavior of unix set_readonly
behavior.
This commit is contained in:
parent
c774c95919
commit
1949c6599d
@ -170,11 +170,17 @@ impl AsInner<stat64> for FileAttr {
|
||||
}
|
||||
|
||||
impl FilePermissions {
|
||||
pub fn readonly(&self) -> bool { self.mode & 0o222 == 0 }
|
||||
pub fn readonly(&self) -> bool {
|
||||
// check if any class (owner, group, others) has write permission
|
||||
self.mode & 0o222 == 0
|
||||
}
|
||||
|
||||
pub fn set_readonly(&mut self, readonly: bool) {
|
||||
if readonly {
|
||||
// remove write permission for all classes; equivalent to `chmod a-w <file>`
|
||||
self.mode &= !0o222;
|
||||
} else {
|
||||
// add write permission for all classes; equivalent to `chmod a+w <file>`
|
||||
self.mode |= 0o222;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user