Skip to content

Commit e0a9dd3

Browse files
committed
uefi: fs: Partially implement FileAttr
- Just the permission and file type. - FileTimes will need some new conversion functions and thus will come with a future PR. Trying to keep things simple here. Signed-off-by: Ayush Singh <[email protected]>
1 parent c717cc7 commit e0a9dd3

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

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

+11-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ const FILE_PERMISSIONS_MASK: u64 = r_efi::protocols::file::READ_ONLY;
1111

1212
pub struct File(!);
1313

14-
pub struct FileAttr(!);
14+
#[derive(Clone)]
15+
pub struct FileAttr {
16+
attr: u64,
17+
size: u64,
18+
}
1519

1620
pub struct ReadDir(!);
1721

@@ -36,33 +40,27 @@ pub struct DirBuilder {}
3640

3741
impl FileAttr {
3842
pub fn size(&self) -> u64 {
39-
self.0
43+
self.size
4044
}
4145

4246
pub fn perm(&self) -> FilePermissions {
43-
self.0
47+
FilePermissions::from_attr(self.attr)
4448
}
4549

4650
pub fn file_type(&self) -> FileType {
47-
self.0
51+
FileType::from_attr(self.attr)
4852
}
4953

5054
pub fn modified(&self) -> io::Result<SystemTime> {
51-
self.0
55+
unsupported()
5256
}
5357

5458
pub fn accessed(&self) -> io::Result<SystemTime> {
55-
self.0
59+
unsupported()
5660
}
5761

5862
pub fn created(&self) -> io::Result<SystemTime> {
59-
self.0
60-
}
61-
}
62-
63-
impl Clone for FileAttr {
64-
fn clone(&self) -> FileAttr {
65-
self.0
63+
unsupported()
6664
}
6765
}
6866

@@ -75,7 +73,6 @@ impl FilePermissions {
7573
self.0 = readonly
7674
}
7775

78-
#[expect(dead_code)]
7976
const fn from_attr(attr: u64) -> Self {
8077
Self(attr & r_efi::protocols::file::READ_ONLY != 0)
8178
}
@@ -105,7 +102,6 @@ impl FileType {
105102
false
106103
}
107104

108-
#[expect(dead_code)]
109105
const fn from_attr(attr: u64) -> Self {
110106
Self(attr & r_efi::protocols::file::DIRECTORY != 0)
111107
}

0 commit comments

Comments
 (0)