Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement masking in FileType comparison on Unix
Fixes: #104900
  • Loading branch information
krtab committed Nov 25, 2022
commit 77005950f09d2f9ba54962bf5adc3f2bc3a7213f
11 changes: 10 additions & 1 deletion library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down