fixed unsafe shell call on windows (#8372)

This commit is contained in:
Marek Kotewicz 2018-04-11 18:21:29 +02:00 committed by André Silva
parent 1356d6d8d5
commit 0a170efaa5

View File

@ -23,6 +23,7 @@ pub fn open(url: &str) {
use winapi::um::shellapi::ShellExecuteA; use winapi::um::shellapi::ShellExecuteA;
use winapi::um::winuser::SW_SHOWNORMAL as Normal; use winapi::um::winuser::SW_SHOWNORMAL as Normal;
unsafe {
ShellExecuteA(ptr::null_mut(), ShellExecuteA(ptr::null_mut(),
CString::new("open").unwrap().as_ptr(), CString::new("open").unwrap().as_ptr(),
CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(), CString::new(url.to_owned().replace("\n", "%0A")).unwrap().as_ptr(),
@ -30,6 +31,7 @@ pub fn open(url: &str) {
ptr::null(), ptr::null(),
Normal); Normal);
} }
}
#[cfg(any(target_os="macos", target_os="freebsd"))] #[cfg(any(target_os="macos", target_os="freebsd"))]
pub fn open(url: &str) { pub fn open(url: &str) {