Skip to content

Commit 8b4e155

Browse files
committed
fix(rustup): (07560d233 2015-04-20) (built 2015-04-19)
* use std::io consistently * adjust to improved `Command` API Related to Byron/google-apis-rs#70
1 parent 30c96b1 commit 8b4e155

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "open"
4-
version = "1.0.2"
4+
version = "1.0.3"
55
authors = ["Sebastian Thiel <[email protected]>"]
66
license = "MIT"
77
description = "Open a path or URL using the program configured on the system"

src/lib.rs

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(old_io)]
21
//! Use this library to open a path or URL using the program configured on the system.
32
//!
43
//! # Usage
@@ -19,30 +18,36 @@
1918
//! As an operating system program is used, chances are that the open operation fails.
2019
//! Therfore, you are advised to at least check the result with `.is_err()` and
2120
//! behave accordingly, e.g. by letting the user know what you tried to open, and failed.
22-
use std::old_io::IoResult;
23-
use std::old_io::process::{Command, ProcessExit};
21+
use std::io;
22+
use std::process::{Command, ExitStatus};
2423

2524
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
26-
pub fn that(path: &str) -> IoResult<ProcessExit> {
27-
use std::old_io::IoError;
28-
29-
let mut res = Err(IoError::from_errno(0, false));
25+
pub fn that(path: &str) -> io::Result<ExitStatus> {
26+
let mut last_err: io::Result<ExitStatus> = Err(io::Error::from_raw_os_error(0));
3027
for program in &["xdg-open", "gnome-open", "kde-open"] {
31-
res = Command::new(program).arg(path).detached().status();
32-
match res {
33-
Ok(_) => return res,
34-
Err(_) => continue,
28+
match Command::new(program).arg(path).spawn() {
29+
Ok(mut child) => return child.wait(),
30+
Err(err) => {
31+
last_err = Err(err);
32+
continue;
33+
},
3534
}
3635
}
37-
res
36+
last_err
3837
}
3938

4039
#[cfg(target_os = "windows")]
41-
pub fn that(path: &str) -> IoResult<ProcessExit> {
42-
Command::new("start").arg(path).detached().status()
40+
pub fn that(path: &str) -> io::Result<ExitStatus> {
41+
match Command::new("start").arg(path).spawn() {
42+
Ok(mut child) => child.wait(),
43+
Err(err) => Err(err),
44+
}
4345
}
4446

4547
#[cfg(target_os = "macos")]
46-
pub fn that(path: &str) -> IoResult<ProcessExit> {
47-
Command::new("open").arg(path).detached().status()
48+
pub fn that(path: &str) -> io::Result<ExitStatus> {
49+
match Command::new("open").arg(path).spawn() {
50+
Ok(mut child) => child.wait(),
51+
Err(err) => Err(err),
52+
}
4853
}

0 commit comments

Comments
 (0)