@@ -63,11 +63,13 @@ impl FileSystem {
63
63
let mut src = self
64
64
. open ( src_path, UefiFileMode :: Read , false ) ?
65
65
. into_regular_file ( )
66
- . ok_or ( Error :: Io ( IoError {
67
- path : src_path. to_path_buf ( ) ,
68
- context : IoErrorContext :: NotAFile ,
69
- uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
70
- } ) ) ?;
66
+ . ok_or_else ( || {
67
+ Error :: Io ( IoError {
68
+ path : src_path. to_path_buf ( ) ,
69
+ context : IoErrorContext :: NotAFile ,
70
+ uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
71
+ } )
72
+ } ) ?;
71
73
72
74
// Get the source file's size in bytes.
73
75
let src_size = {
@@ -91,11 +93,13 @@ impl FileSystem {
91
93
let mut dest = self
92
94
. open ( dest_path, UefiFileMode :: CreateReadWrite , false ) ?
93
95
. into_regular_file ( )
94
- . ok_or ( Error :: Io ( IoError {
95
- path : dest_path. to_path_buf ( ) ,
96
- context : IoErrorContext :: OpenError ,
97
- uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
98
- } ) ) ?;
96
+ . ok_or_else ( || {
97
+ Error :: Io ( IoError {
98
+ path : dest_path. to_path_buf ( ) ,
99
+ context : IoErrorContext :: OpenError ,
100
+ uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
101
+ } )
102
+ } ) ?;
99
103
100
104
// 1 MiB copy buffer.
101
105
let mut chunk = vec ! [ 0 ; 1024 * 1024 ] ;
@@ -198,13 +202,15 @@ impl FileSystem {
198
202
let mut file = self
199
203
. open ( path, UefiFileMode :: Read , false ) ?
200
204
. into_regular_file ( )
201
- . ok_or ( Error :: Io ( IoError {
202
- path : path. to_path_buf ( ) ,
203
- context : IoErrorContext :: NotAFile ,
204
- // We do not have a real UEFI error here as we have a logical
205
- // problem.
206
- uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
207
- } ) ) ?;
205
+ . ok_or_else ( || {
206
+ Error :: Io ( IoError {
207
+ path : path. to_path_buf ( ) ,
208
+ context : IoErrorContext :: NotAFile ,
209
+ // We do not have a real UEFI error here as we have a logical
210
+ // problem.
211
+ uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
212
+ } )
213
+ } ) ?;
208
214
209
215
let info = file. get_boxed_info :: < UefiFileInfo > ( ) . map_err ( |err| {
210
216
Error :: Io ( IoError {
@@ -237,13 +243,15 @@ impl FileSystem {
237
243
let dir = self
238
244
. open ( path, UefiFileMode :: Read , false ) ?
239
245
. into_directory ( )
240
- . ok_or ( Error :: Io ( IoError {
241
- path : path. to_path_buf ( ) ,
242
- context : IoErrorContext :: NotADirectory ,
243
- // We do not have a real UEFI error here as we have a logical
244
- // problem.
245
- uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
246
- } ) ) ?;
246
+ . ok_or_else ( || {
247
+ Error :: Io ( IoError {
248
+ path : path. to_path_buf ( ) ,
249
+ context : IoErrorContext :: NotADirectory ,
250
+ // We do not have a real UEFI error here as we have a logical
251
+ // problem.
252
+ uefi_error : Status :: INVALID_PARAMETER . into ( ) ,
253
+ } )
254
+ } ) ?;
247
255
Ok ( UefiDirectoryIter :: new ( dir) )
248
256
}
249
257
0 commit comments