mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
Implement masking in FileType comparison on Unix
Fixes: https://github.com/rust-lang/rust/issues/104900
This commit is contained in:
parent
e704e95250
commit
77005950f0
@ -332,11 +332,16 @@ pub struct FileTimes {
|
||||
modified: Option<SystemTime>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Copy, Clone, Eq, Hash, Debug)]
|
||||
pub struct FileType {
|
||||
mode: mode_t,
|
||||
}
|
||||
|
||||
impl PartialEq for FileType {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.masked() == other.masked()
|
||||
}
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct DirBuilder {
|
||||
mode: mode_t,
|
||||
@ -550,6 +555,10 @@ impl FileType {
|
||||
pub fn is(&self, mode: mode_t) -> bool {
|
||||
self.mode & libc::S_IFMT == mode
|
||||
}
|
||||
|
||||
fn masked(&self) -> mode_t {
|
||||
self.mode & libc::S_IFMT
|
||||
}
|
||||
}
|
||||
|
||||
impl FromInner<u32> for FilePermissions {
|
||||
|
Loading…
Reference in New Issue
Block a user