From b2a79f6b93feef3a59ce57d865334d757e642540 Mon Sep 17 00:00:00 2001 From: hybras <24651269+hybras@users.noreply.github.com> Date: Wed, 3 Mar 2021 08:49:22 -0500 Subject: [PATCH 1/2] Revert "Use the file explorer to open windows url's" This reverts commit 45454254b6e07fd88e398e8de86b55863f369373. --- src/lib.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0a0b2ec..2c87321 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,7 +107,25 @@ mod windows { } pub fn that + Sized>(path: T) -> io::Result { - Command::new("explorer").arg(path).spawn()?.wait() + const SW_SHOW: c_int = 5; + + let path = convert_path(path.as_ref())?; + let operation: Vec = OsStr::new("open\0").encode_wide().collect(); + let result = unsafe { + ShellExecuteW( + ptr::null_mut(), + operation.as_ptr(), + path.as_ptr(), + ptr::null(), + ptr::null(), + SW_SHOW, + ) + }; + if result as c_int > 32 { + Ok(ExitStatus::from_raw(0)) + } else { + Err(io::Error::last_os_error()) + } } pub fn with + Sized>( From 7ff85da679de7cd17155c4ea27d0f89fda6dff0a Mon Sep 17 00:00:00 2001 From: hybras <24651269+hybras@users.noreply.github.com> Date: Wed, 3 Mar 2021 08:55:16 -0500 Subject: [PATCH 2/2] Revert "Add missing Command import" This reverts commit c9102785d58cc955595eb189bd89a2ff82a539f0. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2c87321..d0647f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,7 @@ mod windows { use std::ffi::OsStr; use std::io; use std::os::windows::{ffi::OsStrExt, process::ExitStatusExt}; - use std::process::{Command, ExitStatus}; + use std::process::ExitStatus; use std::ptr; use winapi::ctypes::c_int;