Skip to content

Commit

Permalink
Fix windows file chooser (was broken in ca120e9)
Browse files Browse the repository at this point in the history
- printed output would appear as file chooser parth
- don't attempt to change dir if file is opened as a file chooser
  • Loading branch information
drojf committed Sep 8, 2020
1 parent ade2faa commit 49b8415
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions install_loader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,7 @@ fn fix_cwd() -> Result<PathBuf, Box<dyn Error>> {
fn main() -> Result<(), Box<dyn Error>> {
panic_handler::set_hook(String::from("07th-mod_crash.log"));

// Change current directory to .exe path, if current .exe path is known
let old_cwd = std::env::current_dir();
match fix_cwd() {
Ok(new_cwd) => println!(
"Successfully changed path from {:?} to {:?}",
old_cwd, new_cwd
),
Err(e) => println!(
"Couldn't fix exe path - cwd remains as [{:?}]. Error: [{}]",
std::env::current_dir(),
e
),
}

//////////////////////////// Begin file chooser code ///////////////////////////////////////////
let open_about_msg = r#"Shows an open dialog and:
- if user selected a path, writes the chosen path to stdout, returns 0
- if user cancelled, writes nothing to stdout, returns 0
Expand All @@ -86,6 +73,21 @@ For example, open "text and pdf" "*.txt;*.pdf" "main c file" "main.c""#;
return handle_open_command(matches);
}

//////////////////////////// Begin normal installer code ///////////////////////////////////////
// Change current directory to .exe path, if current .exe path is known
let old_cwd = std::env::current_dir();
match fix_cwd() {
Ok(new_cwd) => println!(
"Successfully changed path from {:?} to {:?}",
old_cwd, new_cwd
),
Err(e) => println!(
"Couldn't fix exe path - cwd remains as [{:?}]. Error: [{}]",
std::env::current_dir(),
e
),
}

// _maybe_job must be kept in scope for the remainder of the program!
let (_maybe_job, register_job_result) = windows_utilities::new_job_kill_on_job_close();

Expand Down

0 comments on commit 49b8415

Please sign in to comment.