FFI: Fix tracing log path handling on Windows

Windows uses u16 for OS strings, requiring an owned OsString when
converting to Rust. This needs to be stored in its own variable, so we
can take an immutable reference to it in Path::new.
This commit is contained in:
Jack Grigg 2020-08-10 23:02:43 +01:00
parent 682bc15757
commit a7f695dbae
1 changed files with 3 additions and 3 deletions

View File

@ -68,12 +68,12 @@ pub extern "C" fn tracing_init(
let log_path = unsafe { slice::from_raw_parts(log_path, log_path_len) };
#[cfg(not(target_os = "windows"))]
let log_path = Path::new(OsStr::from_bytes(log_path));
let log_path = OsStr::from_bytes(log_path);
#[cfg(target_os = "windows")]
let log_path = Path::new(OsString::from_wide(log_path));
let log_path = OsString::from_wide(log_path);
tracing_init_file(log_path, initial_filter, log_timestamps)
tracing_init_file(Path::new(&log_path), initial_filter, log_timestamps)
}
}