microsoft/openvmm
Publicmirrored fromhttps://github.com/microsoft/openvmmAvailable
flowey/flowey_lib_common/src/_util/wslpath.rs
26lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use std::path::PathBuf; |
| 5 | |
| 6 | pub fn win_to_linux(path: impl AsRef<std::path::Path>) -> PathBuf { |
| 7 | let sh = xshell::Shell::new().unwrap(); |
| 8 | let path = path.as_ref(); |
| 9 | xshell::cmd!(sh, "wslpath {path}") |
| 10 | .quiet() |
| 11 | .ignore_status() |
| 12 | .read() |
| 13 | .unwrap() |
| 14 | .into() |
| 15 | } |
| 16 | |
| 17 | pub fn linux_to_win(path: impl AsRef<std::path::Path>) -> PathBuf { |
| 18 | let sh = xshell::Shell::new().unwrap(); |
| 19 | let path = path.as_ref(); |
| 20 | xshell::cmd!(sh, "wslpath -aw {path}") |
| 21 | .quiet() |
| 22 | .ignore_status() |
| 23 | .read() |
| 24 | .unwrap() |
| 25 | .into() |
| 26 | } |
| 27 | |