Skip to content

Commit 049f698

Browse files
authored
Merge pull request #28 from aspenluxxxy/ios
Add iOS support
2 parents ef91705 + 00119a7 commit 049f698

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/lib.rs

+45
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ pub use windows::{that, with};
5555
#[cfg(target_os = "macos")]
5656
pub use macos::{that, with};
5757

58+
#[cfg(target_os = "ios")]
59+
pub use ios::{that, with};
60+
5861
#[cfg(any(
5962
target_os = "linux",
6063
target_os = "android",
@@ -66,6 +69,19 @@ pub use macos::{that, with};
6669
))]
6770
pub use unix::{that, with};
6871

72+
#[cfg(not(any(
73+
target_os = "dragonfly",
74+
target_os = "freebsd",
75+
target_os = "ios",
76+
target_os = "linux",
77+
target_os = "macos",
78+
target_os = "netbsd",
79+
target_os = "openbsd",
80+
target_os = "solaris",
81+
target_os = "windows",
82+
)))]
83+
compile_error!("open is not supported on this platform");
84+
6985
/// Convenience function for opening the passed path in a new thread.
7086
/// See documentation of `that(...)` for more details.
7187
pub fn that_in_background<T: AsRef<OsStr> + Sized>(
@@ -187,6 +203,35 @@ mod macos {
187203
}
188204
}
189205

206+
#[cfg(target_os = "ios")]
207+
mod ios {
208+
use std::{
209+
ffi::OsStr,
210+
io::Result,
211+
process::{Command, ExitStatus, Stdio},
212+
};
213+
214+
pub fn that<T: AsRef<OsStr> + Sized>(path: T) -> Result<ExitStatus> {
215+
Command::new("uiopen")
216+
.stdout(Stdio::null())
217+
.stderr(Stdio::null())
218+
.arg("--url")
219+
.arg(path.as_ref())
220+
.spawn()?
221+
.wait()
222+
}
223+
224+
pub fn with<T: AsRef<OsStr> + Sized>(path: T, app: impl Into<String>) -> Result<ExitStatus> {
225+
Command::new("uiopen")
226+
.arg("--url")
227+
.arg(path.as_ref())
228+
.arg("--bundleid")
229+
.arg(app.into())
230+
.spawn()?
231+
.wait()
232+
}
233+
}
234+
190235
#[cfg(any(
191236
target_os = "linux",
192237
target_os = "android",

0 commit comments

Comments
 (0)