Skip to content

Commit

Permalink
Revert "Use the file explorer to open windows url's"
Browse files Browse the repository at this point in the history
This reverts commit 4545425.
  • Loading branch information
hybras committed Mar 3, 2021
1 parent 6c6bad0 commit b2a79f6
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,25 @@ mod windows {
}

pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> io::Result<ExitStatus> {
Command::new("explorer").arg(path).spawn()?.wait()
const SW_SHOW: c_int = 5;

let path = convert_path(path.as_ref())?;
let operation: Vec<u16> = 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<T: AsRef<OsStr> + Sized>(
Expand Down

0 comments on commit b2a79f6

Please sign in to comment.