Skip to content

Commit c717cc7

Browse files
committed
uefi: fs: Implement FileType
- Similar to FilePermissions, using bool to represent the bitfield. - FileType cannot be changed, so no need to worry about converting back to attribute. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
1 parent 1833737 commit c717cc7

1 file changed

Lines changed: 10 additions & 30 deletions

File tree

‎library/std/src/sys/fs/uefi.rs‎

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
usecrate::ffi::OsString;
22
usecrate::fmt;
3-
usecrate::hash::{Hash,Hasher};
3+
usecrate::hash::Hash;
44
usecrate::io::{self,BorrowedCursor,IoSlice,IoSliceMut,SeekFrom};
55
usecrate::path::{Path,PathBuf};
66
usecrate::sys::time::SystemTime;
@@ -27,7 +27,9 @@ pub struct FileTimes {}
2727
// Bool indicates if file is readonly
2828
pubstructFilePermissions(bool);
2929

30-
pubstructFileType(!);
30+
#[derive(Clone,Copy,PartialEq,Eq,Hash,Debug)]
31+
// Bool indicates if directory
32+
pubstructFileType(bool);
3133

3234
#[derive(Debug)]
3335
pubstructDirBuilder{}
@@ -95,39 +97,17 @@ impl FileType {
9597
}
9698

9799
pubfnis_file(&self) -> bool{
98-
self.0
100+
!self.is_dir()
99101
}
100102

103+
// Symlinks are not supported in UEFI
101104
pubfnis_symlink(&self) -> bool{
102-
self.0
105+
false
103106
}
104-
}
105107

106-
implCloneforFileType{
107-
fnclone(&self) -> FileType{
108-
self.0
109-
}
110-
}
111-
112-
implCopyforFileType{}
113-
114-
implPartialEqforFileType{
115-
fneq(&self,_other:&FileType) -> bool{
116-
self.0
117-
}
118-
}
119-
120-
implEqforFileType{}
121-
122-
implHashforFileType{
123-
fnhash<H:Hasher>(&self,_h:&mutH){
124-
self.0
125-
}
126-
}
127-
128-
impl fmt::DebugforFileType{
129-
fnfmt(&self,_f:&mut fmt::Formatter<'_>) -> fmt::Result{
130-
self.0
108+
#[expect(dead_code)]
109+
constfnfrom_attr(attr:u64) -> Self{
110+
Self(attr & r_efi::protocols::file::DIRECTORY != 0)
131111
}
132112
}
133113

0 commit comments

Comments
 (0)