@@ -12,12 +12,28 @@ use crate::sys::unsupported;
1212#[ expect( dead_code) ]
1313const FILE_PERMISSIONS_MASK : u64 = r_efi:: protocols:: file:: READ_ONLY ;
1414
15+ const ZERO_TIME : r_efi:: efi:: Time = r_efi:: efi:: Time {
16+ year : 0 ,
17+ month : 0 ,
18+ day : 0 ,
19+ hour : 0 ,
20+ minute : 0 ,
21+ second : 0 ,
22+ nanosecond : 0 ,
23+ timezone : 0 ,
24+ daylight : 0 ,
25+ pad1 : 0 ,
26+ pad2 : 0 ,
27+ } ;
28+
1529pub struct File ( !) ;
1630
1731#[ derive( Clone ) ]
1832pub struct FileAttr {
1933 attr : u64 ,
2034 size : u64 ,
35+ created : r_efi:: efi:: Time ,
36+ times : FileTimes ,
2137}
2238
2339pub struct ReadDir ( !) ;
@@ -32,8 +48,11 @@ pub struct OpenOptions {
3248 create_new : bool ,
3349}
3450
35- #[ derive( Copy , Clone , Debug , Default ) ]
36- pub struct FileTimes { }
51+ #[ derive( Copy , Clone , Debug ) ]
52+ pub struct FileTimes {
53+ accessed : r_efi:: efi:: Time ,
54+ modified : r_efi:: efi:: Time ,
55+ }
3756
3857#[ derive( Clone , PartialEq , Eq , Debug ) ]
3958// Bool indicates if file is readonly
@@ -60,15 +79,15 @@ impl FileAttr {
6079 }
6180
6281 pub fn modified ( & self ) -> io:: Result < SystemTime > {
63- unsupported ( )
82+ Ok ( SystemTime :: from_uefi ( self . times . modified ) )
6483 }
6584
6685 pub fn accessed ( & self ) -> io:: Result < SystemTime > {
67- unsupported ( )
86+ Ok ( SystemTime :: from_uefi ( self . times . accessed ) )
6887 }
6988
7089 pub fn created ( & self ) -> io:: Result < SystemTime > {
71- unsupported ( )
90+ Ok ( SystemTime :: from_uefi ( self . created ) )
7291 }
7392}
7493
@@ -92,8 +111,21 @@ impl FilePermissions {
92111}
93112
94113impl FileTimes {
95- pub fn set_accessed ( & mut self , _t : SystemTime ) { }
96- pub fn set_modified ( & mut self , _t : SystemTime ) { }
114+ pub fn set_accessed ( & mut self , t : SystemTime ) {
115+ self . accessed =
116+ t. to_uefi ( self . accessed . timezone , self . accessed . daylight ) . expect ( "Invalid Time" ) ;
117+ }
118+
119+ pub fn set_modified ( & mut self , t : SystemTime ) {
120+ self . modified =
121+ t. to_uefi ( self . modified . timezone , self . modified . daylight ) . expect ( "Invalid Time" ) ;
122+ }
123+ }
124+
125+ impl Default for FileTimes {
126+ fn default ( ) -> Self {
127+ Self { modified : ZERO_TIME , accessed : ZERO_TIME }
128+ }
97129}
98130
99131impl FileType {
0 commit comments