From 91437906022975fd6bfd072ee9811168d2e7cacf Mon Sep 17 00:00:00 2001 From: Petros Amoiridis Date: Sat, 11 Feb 2023 11:12:46 +0200 Subject: [PATCH] Include code only on macOS Co-Authored-By: Mikayla Maki --- crates/util/src/lib.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/util/src/lib.rs b/crates/util/src/lib.rs index 5b12502389b206894005a363e6816103da63f5f0..c3376f2e786a97630fc2d0e6cf17657ca357a7ac 100644 --- a/crates/util/src/lib.rs +++ b/crates/util/src/lib.rs @@ -56,19 +56,25 @@ pub fn truncate_and_trailoff(s: &str, max_chars: usize) -> String { pub fn open>(path: P) { let path_to_open = path.as_ref().to_string_lossy(); - std::process::Command::new("open") - .arg(path_to_open.as_ref()) - .spawn() - .log_err(); + #[cfg(target_os = "macos")] + { + std::process::Command::new("open") + .arg(path_to_open.as_ref()) + .spawn() + .log_err(); + } } pub fn reveal_in_finder>(path: P) { let path_to_reveal = path.as_ref().to_string_lossy(); - std::process::Command::new("open") - .arg("-R") // To reveal in Finder instead of opening the file - .arg(path_to_reveal.as_ref()) - .spawn() - .log_err(); + #[cfg(target_os = "macos")] + { + std::process::Command::new("open") + .arg("-R") // To reveal in Finder instead of opening the file + .arg(path_to_reveal.as_ref()) + .spawn() + .log_err(); + } } pub fn post_inc + AddAssign + Copy>(value: &mut T) -> T {