Skip to content

Commit

Permalink
Use the file explorer to open windows url's
Browse files Browse the repository at this point in the history
Specific to open::that
  • Loading branch information
hybras committed Feb 23, 2021
1 parent db518e9 commit 4545425
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,7 @@ mod windows {
}

pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> io::Result<ExitStatus> {
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())
}
Command::new("explorer").arg(path).spawn()?.wait()
}

pub fn with<T: AsRef<OsStr> + Sized>(
Expand Down

0 comments on commit 4545425

Please sign in to comment.