Skip to content

Commit 7ab725a

Browse files
committed
refactor
- fix build - don't quote path anymore as it's seemingly not required. After all, we are passing the argument directly.
1 parent 056cb00 commit 7ab725a

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

src/windows.rs

+4-32
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,9 @@
1-
use std::{
2-
ffi::{OsStr, OsString},
3-
io,
4-
os::windows::ffi::OsStrExt,
5-
ptr,
6-
};
1+
use std::{ffi::OsStr, io};
72

8-
use std::os::raw::c_int;
9-
10-
use crate::IntoResult;
11-
12-
fn convert_path(path: &OsStr) -> io::Result<Vec<u16>> {
13-
let mut quoted_path = OsString::with_capacity(path.len());
14-
15-
// Surround path with double quotes "" to handle spaces in path.
16-
quoted_path.push("\"");
17-
quoted_path.push(&path);
18-
quoted_path.push("\"");
19-
20-
let mut wide_chars: Vec<_> = quoted_path.encode_wide().collect();
21-
if wide_chars.iter().any(|&u| u == 0) {
22-
return Err(io::Error::new(
23-
io::ErrorKind::InvalidInput,
24-
"path contains NUL byte(s)",
25-
));
26-
}
27-
wide_chars.push(0);
28-
Ok(wide_chars)
29-
}
3+
use crate::{CommandExt, IntoResult};
304

315
pub fn that<T: AsRef<OsStr>>(path: T) -> io::Result<()> {
32-
let path = convert_path(path.as_ref())?;
33-
Command::new("cmd")
6+
std::process::Command::new("cmd")
347
.arg("/c")
358
.arg("start")
369
.arg(path.as_ref())
@@ -39,8 +12,7 @@ pub fn that<T: AsRef<OsStr>>(path: T) -> io::Result<()> {
3912
}
4013

4114
pub fn with<T: AsRef<OsStr>>(path: T, app: impl Into<String>) -> io::Result<()> {
42-
let path = convert_path(path.as_ref())?;
43-
Command::new("cmd")
15+
std::process::Command::new("cmd")
4416
.arg("/c")
4517
.arg(app.into())
4618
.arg(path.as_ref())

0 commit comments

Comments
 (0)