mirror of
https://github.com/rfvgyhn/min-ed-launcher.git
synced 2026-02-04 10:45:34 +00:00
fix bootstrapper not being able to write errors when log dir doesn't exist
This commit is contained in:
@ -16,6 +16,9 @@
|
||||
|
||||
If you relied on this behavior, you'll need to append `/autorun` to your launch options going forward.
|
||||
|
||||
### Bug fixes
|
||||
- Prevent bootstrapper from not logging errors if log directory didn't already exist
|
||||
|
||||
## [0.9.0] - 2023-09-12
|
||||
|
||||
### New Features
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
compile_error!("Can only be built on Windows");
|
||||
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::Write;
|
||||
use std::os::windows::ffi::OsStrExt;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
use windows::core::{w, PCWSTR};
|
||||
use windows::Win32::Foundation::GetLastError;
|
||||
use windows::Win32::UI::Shell::{
|
||||
@ -50,12 +50,18 @@ fn write_error(msg: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
]
|
||||
.iter()
|
||||
.collect();
|
||||
|
||||
let write = fs::create_dir_all(&file_path.parent().unwrap()).and_then(|()| {
|
||||
let mut file = OpenOptions::new()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(&file_path)?;
|
||||
|
||||
if let Err(e) = writeln!(&mut file, "Bootstrapper Error MinEdLauncher.exe: {}", msg) {
|
||||
eprintln!("Bootstrapper Error MinEdLauncher.exe: {}", msg);
|
||||
writeln!(&mut file, "Bootstrapper Error MinEdLauncher.exe: {}", msg)
|
||||
});
|
||||
|
||||
if let Err(e) = write {
|
||||
eprintln!("Couldn't write to {}: {}", file_path.display(), e);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user