Skip to content

Commit

Permalink
feat: show error when failing to open osu! dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rushiiMachine committed Dec 25, 2024
1 parent c10cd02 commit accfde4
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,23 @@ fn configure(_: &Context) {
default_osu_path.to_string()
} else {
println!("Could not detect osu installation! Please enter your osu! directory path below:");
let mut path = String::new();
for in_path in stdin.lock().lines() {
let in_path = in_path.unwrap();

if !Path::new(&format!("{in_path}/osu!.exe")).exists() {
println!("Invalid osu installation! (osu!.exe missing)");
continue;
}

path = in_path;
break;
}
path
stdin.lock().lines()
.filter_map(|input| input.ok())
.find(|input| {
match fs::exists(&*format!("{input}/osu!.exe")) {
Err(err) => {
println!("Invalid osu installation: {err}");
false
}
Ok(false) => {
println!("Invalid osu installation! (osu!.exe missing)");
false
}
Ok(true) => true
}
})
.unwrap()
};

let mut servers = Vec::from(["osu.ppy.sh".to_string()]);
Expand Down

0 comments on commit accfde4

Please sign in to comment.