diff --git a/library/std/src/sys/fs/uefi.rs b/library/std/src/sys/fs/uefi.rs index 5763d7862f5ae..4c80453ba766c 100644 --- a/library/std/src/sys/fs/uefi.rs +++ b/library/std/src/sys/fs/uefi.rs @@ -18,6 +18,8 @@ pub struct File(!); pub struct FileAttr { attr: u64, size: u64, + created: r_efi::efi::Time, + times: FileTimes, } pub struct ReadDir(!); @@ -33,7 +35,10 @@ pub struct OpenOptions { } #[derive(Copy, Clone, Debug, Default)] -pub struct FileTimes {} +pub struct FileTimes { + accessed: r_efi::efi::Time, + modified: r_efi::efi::Time, +} #[derive(Clone, PartialEq, Eq, Debug)] // Bool indicates if file is readonly @@ -60,15 +65,15 @@ impl FileAttr { } pub fn modified(&self) -> io::Result { - unsupported() + Ok(SystemTime::from_uefi(self.times.modified)) } pub fn accessed(&self) -> io::Result { - unsupported() + Ok(SystemTime::from_uefi(self.times.accessed)) } pub fn created(&self) -> io::Result { - unsupported() + Ok(SystemTime::from_uefi(self.created)) } } @@ -92,8 +97,15 @@ impl FilePermissions { } impl FileTimes { - pub fn set_accessed(&mut self, _t: SystemTime) {} - pub fn set_modified(&mut self, _t: SystemTime) {} + pub fn set_accessed(&mut self, t: SystemTime) { + self.accessed = + t.to_uefi(self.accessed.timezone, self.accessed.daylight).expect("Invalid Time"); + } + + pub fn set_modified(&mut self, t: SystemTime) { + self.modified = + t.to_uefi(self.modified.timezone, self.modified.daylight).expect("Invalid Time"); + } } impl FileType { diff --git a/library/std/src/sys/pal/uefi/time.rs b/library/std/src/sys/pal/uefi/time.rs index a5ab76903274d..475b5e7e35a7b 100644 --- a/library/std/src/sys/pal/uefi/time.rs +++ b/library/std/src/sys/pal/uefi/time.rs @@ -70,7 +70,6 @@ impl SystemTime { Self(system_time_internal::from_uefi(&t)) } - #[expect(dead_code)] pub(crate) const fn to_uefi(self, timezone: i16, daylight: u8) -> Option { system_time_internal::to_uefi(&self.0, timezone, daylight) }