fixed a bug in show in explorer on windows

This commit is contained in:
Dmitry Stepanov
2025-05-02 23:06:05 +03:00
parent b4ffa5bc03
commit 55a65f25d0
+23 -4
View File
@@ -69,6 +69,7 @@ use crate::{
Message, Mode,
};
use notify::{EventKind, RecommendedWatcher, RecursiveMode, Watcher};
use std::process::Command;
use std::{
ffi::OsStr,
fs::File,
@@ -98,11 +99,29 @@ struct ContextMenu {
dependencies: Handle<UiNode>,
}
fn show_in_explorer<P: AsRef<Path>>(path: P) {
if let Err(err) = opener::reveal(path) {
Log::err(format!(
fn execute_command(command: &mut Command) {
match command.spawn() {
Ok(mut process) => Log::verify(process.wait()),
Err(err) => Log::err(format!(
"Failed to show asset item in explorer. Reason: {err:?}"
))
)),
}
}
fn show_in_explorer<P: AsRef<Path>>(path: P) {
// opener crate is bugged on Windows, so using explorer's command directly.
#[cfg(target_os = "windows")]
{
execute_command(Command::new("explorer").arg("/select,").arg(path.as_ref()))
}
#[cfg(not(target_os = "windows"))]
{
if let Err(err) = opener::reveal(path) {
Log::err(format!(
"Failed to show asset item in explorer. Reason: {err:?}"
))
}
}
}