From 45454254b6e07fd88e398e8de86b55863f369373 Mon Sep 17 00:00:00 2001 From: hybras <24651269+hybras@users.noreply.github.com> Date: Tue, 23 Feb 2021 00:55:41 -0500 Subject: [PATCH] Use the file explorer to open windows url's Specific to open::that --- src/lib.rs | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ac11a02..238a649 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,25 +107,7 @@ mod windows { } pub fn that + Sized>(path: T) -> io::Result { - 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()) - } + Command::new("explorer").arg(path).spawn()?.wait() } pub fn with + Sized>(