File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -17,25 +17,25 @@ struct Platform {
17
17
const CONFIG_FILE : & str = "framework_tool_config.toml" ;
18
18
19
19
#[ cfg( feature = "uefi" ) ]
20
- fn read_config_file ( ) -> String {
21
- crate :: uefi:: fs:: shell_read_file ( CONFIG_FILE )
20
+ fn read_config_file ( ) -> Option < String > {
21
+ Some ( crate :: uefi:: fs:: shell_read_file ( CONFIG_FILE ) )
22
22
}
23
23
#[ cfg( not( feature = "uefi" ) ) ]
24
- fn read_config_file ( ) -> String {
25
- let mut path = std:: env:: current_exe ( ) . unwrap ( ) ;
24
+ fn read_config_file ( ) -> Option < String > {
25
+ let mut path = std:: env:: current_exe ( ) . ok ( ) ? ;
26
26
path. pop ( ) ;
27
27
path. push ( CONFIG_FILE ) ;
28
28
29
29
if let Ok ( str) = std:: fs:: read_to_string ( path) {
30
- str
30
+ Some ( str)
31
31
} else {
32
32
path = CONFIG_FILE . into ( ) ;
33
- std:: fs:: read_to_string ( path) . unwrap ( )
33
+ Some ( std:: fs:: read_to_string ( path) . ok ( ) ? )
34
34
}
35
35
}
36
36
37
37
pub fn load_config ( ) -> Option < util:: Platform > {
38
- let toml_str = read_config_file ( ) ;
38
+ let toml_str = read_config_file ( ) ? ;
39
39
40
40
let decoded: Config = toml:: from_str ( & toml_str) . unwrap ( ) ;
41
41
println ! ( "{:?}" , decoded) ;
You can’t perform that action at this time.
0 commit comments