@@ -12,12 +12,28 @@ use crate::sys::unsupported;
12
12
#[ expect( dead_code) ]
13
13
const FILE_PERMISSIONS_MASK : u64 = r_efi:: protocols:: file:: READ_ONLY ;
14
14
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
+
15
29
pub struct File ( !) ;
16
30
17
31
#[ derive( Clone ) ]
18
32
pub struct FileAttr {
19
33
attr : u64 ,
20
34
size : u64 ,
35
+ created : r_efi:: efi:: Time ,
36
+ times : FileTimes ,
21
37
}
22
38
23
39
pub struct ReadDir ( !) ;
@@ -32,8 +48,11 @@ pub struct OpenOptions {
32
48
create_new : bool ,
33
49
}
34
50
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
+ }
37
56
38
57
#[ derive( Clone , PartialEq , Eq , Debug ) ]
39
58
// Bool indicates if file is readonly
@@ -60,15 +79,15 @@ impl FileAttr {
60
79
}
61
80
62
81
pub fn modified ( & self ) -> io:: Result < SystemTime > {
63
- unsupported ( )
82
+ Ok ( SystemTime :: from_uefi ( self . times . modified ) )
64
83
}
65
84
66
85
pub fn accessed ( & self ) -> io:: Result < SystemTime > {
67
- unsupported ( )
86
+ Ok ( SystemTime :: from_uefi ( self . times . accessed ) )
68
87
}
69
88
70
89
pub fn created ( & self ) -> io:: Result < SystemTime > {
71
- unsupported ( )
90
+ Ok ( SystemTime :: from_uefi ( self . created ) )
72
91
}
73
92
}
74
93
@@ -92,8 +111,21 @@ impl FilePermissions {
92
111
}
93
112
94
113
impl 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
+ }
97
129
}
98
130
99
131
impl FileType {
0 commit comments