mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-12 02:02:20 +00:00
fixed a bug in show in explorer on windows
This commit is contained in:
+23
-4
@@ -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:?}"
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user