forked from Rativel/BurritOS
BurritOS now read configuration file
This commit is contained in:
@@ -15,7 +15,7 @@ use std::{
|
||||
|
||||
/// Aliases the rather long HashMap<MachineSettingKey, i32> type
|
||||
/// to a rather simpler to understand Settings.
|
||||
pub type Settings = HashMap<MachineSettingKey, i32>;
|
||||
pub type Settings = HashMap<MachineSettingKey, u64>;
|
||||
|
||||
/// Keys for the Settings HashMap, represented as enums for
|
||||
/// maintainability.
|
||||
@@ -92,6 +92,13 @@ pub fn read_settings() -> Result<Settings, Error> {
|
||||
Ok(settings_map)
|
||||
}
|
||||
|
||||
pub fn get_debug_configuration() -> Settings {
|
||||
let mut settings_map = Settings::new();
|
||||
settings_map.insert(MachineSettingKey::PageSize, 128);
|
||||
settings_map.insert(MachineSettingKey::NumPhysPages, 400);
|
||||
settings_map
|
||||
}
|
||||
|
||||
fn filter_garbage<R: std::io::Read>(reader: BufReader<R>) -> Vec<String> {
|
||||
reader.lines()
|
||||
.map(|l| l.unwrap())
|
||||
@@ -101,7 +108,7 @@ fn filter_garbage<R: std::io::Read>(reader: BufReader<R>) -> Vec<String> {
|
||||
|
||||
fn update_settings_map(mut settings_map: Settings, key: &str, setting: &str) -> Settings {
|
||||
let key = MachineSettingKey::from(key);
|
||||
let setting = i32::from_str_radix(setting, 10).unwrap_or(0);
|
||||
let setting = u64::from_str_radix(setting, 10).unwrap_or(0);
|
||||
settings_map.insert(key, setting);
|
||||
settings_map
|
||||
}
|
||||
Reference in New Issue
Block a user