flowey_lib_common/_util/
wslpath.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4use flowey::node::prelude::RustRuntimeServices;
5use std::path::Path;
6use std::path::PathBuf;
7
8pub fn win_to_linux(rt: &RustRuntimeServices<'_>, path: impl AsRef<Path>) -> PathBuf {
9    let path = path.as_ref();
10    flowey::shell_cmd!(rt, "wslpath {path}")
11        .quiet()
12        .ignore_status()
13        .read()
14        .unwrap()
15        .into()
16}
17
18pub fn linux_to_win(rt: &RustRuntimeServices<'_>, path: impl AsRef<Path>) -> PathBuf {
19    let path = path.as_ref();
20    flowey::shell_cmd!(rt, "wslpath -aw {path}")
21        .quiet()
22        .ignore_status()
23        .read()
24        .unwrap()
25        .into()
26}