Skip to content

Commit 0ada98e

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 <[email protected]>
1 parent c76e918 commit 0ada98e

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

Diff for: std/src/sys/fs/uefi.rs

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

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

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

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

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

106-
impl Clone for FileType {
107-
fn clone(&self) -> FileType {
108-
self.0
109-
}
110-
}
111-
112-
impl Copy for FileType {}
113-
114-
impl PartialEq for FileType {
115-
fn eq(&self, _other: &FileType) -> bool {
116-
self.0
117-
}
118-
}
119-
120-
impl Eq for FileType {}
121-
122-
impl Hash for FileType {
123-
fn hash<H: Hasher>(&self, _h: &mut H) {
124-
self.0
125-
}
126-
}
127-
128-
impl fmt::Debug for FileType {
129-
fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
130-
self.0
108+
#[expect(dead_code)]
109+
const fn from_attr(attr: u64) -> Self {
110+
Self(attr & r_efi::protocols::file::DIRECTORY != 0)
131111
}
132112
}
133113

0 commit comments

Comments
 (0)