microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
flowey/flowey_lib_common/src/_util/mod.rs
33lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | pub use flowey::util::copy_dir_all; |
| 5 | |
| 6 | use flowey::node::prelude::FlowPlatformKind; |
| 7 | use flowey::node::prelude::RustRuntimeServices; |
| 8 | |
| 9 | pub mod cargo_output; |
| 10 | pub mod extract; |
| 11 | pub mod wslpath; |
| 12 | |
| 13 | // include a "dummy" _rt argument to enforce that this helper should only be |
| 14 | // used in runtime contexts, and not during flow compile-time. |
| 15 | pub fn running_in_wsl(_rt: &mut RustRuntimeServices<'_>) -> bool { |
| 16 | let Ok(output) = std::process::Command::new("wslpath") |
| 17 | .args(["-aw", "/"]) |
| 18 | .output() |
| 19 | else { |
| 20 | return false; |
| 21 | }; |
| 22 | String::from_utf8_lossy(&output.stdout).starts_with(r"\\wsl.localhost") |
| 23 | } |
| 24 | |
| 25 | /// Returns the name of the bsdtar binary to use. On Windows, this is just the |
| 26 | /// inbox tar.exe. Elsewhere, use bsdtar. This will require installing the |
| 27 | /// libarchive-tools package on Debian-based Linux. |
| 28 | pub fn bsdtar_name(rt: &mut RustRuntimeServices<'_>) -> &'static str { |
| 29 | match rt.platform().kind() { |
| 30 | FlowPlatformKind::Windows => "tar.exe", |
| 31 | FlowPlatformKind::Unix => "bsdtar", |
| 32 | } |
| 33 | } |
| 34 | |