feat: add osu! version and release stream retrieval, along with skins count functionality
This commit is contained in:
@@ -52,3 +52,30 @@ pub fn get_osu_user_config<P: AsRef<Path>>(
|
||||
|
||||
return Some(config_map);
|
||||
}
|
||||
|
||||
pub fn get_osu_config<P: AsRef<Path>>(
|
||||
osu_folder_path: P,
|
||||
) -> Option<std::collections::HashMap<String, String>> {
|
||||
// Ensure the osu! folder path is valid
|
||||
if !osu_folder_path.as_ref().exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// get the osu!.cfg file from the osu! folder
|
||||
let osu_config_path = osu_folder_path.as_ref().join("osu!.cfg");
|
||||
if !osu_config_path.exists() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// read the osu config and return it as a map, key and value are separated by ' = '
|
||||
let mut config_map = std::collections::HashMap::new();
|
||||
if let Ok(contents) = std::fs::read_to_string(osu_config_path) {
|
||||
for line in contents.lines() {
|
||||
if let Some((key, value)) = line.split_once(" = ") {
|
||||
config_map.insert(key.trim().to_string(), value.trim().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Some(config_map);
|
||||
}
|
||||
|
Reference in New Issue
Block a user