Skip to content

Commit de2f7d3

Browse files
committed
config: Read config file in UEFI
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent dc28506 commit de2f7d3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

framework_lib/src/config.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,26 @@ struct Platform {
1616

1717
const CONFIG_FILE: &str = "framework_tool_config.toml";
1818

19-
pub fn load_config() -> Option<util::Platform> {
19+
#[cfg(feature = "uefi")]
20+
fn read_config_file() -> String {
21+
crate::uefi::fs::shell_read_file(CONFIG_FILE)
22+
}
23+
#[cfg(not(feature = "uefi"))]
24+
fn read_config_file() -> String {
2025
let mut path = std::env::current_exe().unwrap();
2126
path.pop();
2227
path.push(CONFIG_FILE);
2328

24-
let toml_str = if let Ok(str) = std::fs::read_to_string(path) {
29+
if let Ok(str) = std::fs::read_to_string(path) {
2530
str
2631
} else {
2732
path = CONFIG_FILE.into();
2833
std::fs::read_to_string(path).unwrap()
29-
};
34+
}
35+
}
36+
37+
pub fn load_config() -> Option<util::Platform> {
38+
let toml_str = read_config_file();
3039

3140
let decoded: Config = toml::from_str(&toml_str).unwrap();
3241
println!("{:?}", decoded);

0 commit comments

Comments
 (0)