pub fn windows_to_wsl(path: &str) -> Result<String, Box<dyn Error>>Expand description
Convert Windows Path to WSL Path Pass path Uses default distro for execution by default
Examples found in repository?
examples/sample.rs (line 3)
1fn main() {
2 // Convert Windows path to WSL
3 let path = wslpath::windows_to_wsl("C:\\Users").unwrap();
4 println!("Windows Path converted to WSL is {}", path);
5 // OUTPUT is
6 // Windows Path converted to WSL is /mnt/c/Users
7
8 // Convert WSL path to Windows
9 let path = wslpath::wsl_to_windows("/mnt/c/Users").unwrap();
10 println!("WSL Path converted to Windows is {}", path);
11 // OUTPUT is
12 // WSL Path converted to Windows is C:/Users
13
14 // Converting Windows Path to WSL Path with a specific distro
15 let path = wslpath::windows_to_wsl_with_distro("C:\\Users", "Ubuntu".to_string()).unwrap();
16 println!("Windows Path converted to WSL is {}", path);
17 // OUTPUT is
18 // Windows Path converted to WSL is /mnt/c/Users
19
20 // Converting WSL Path to Windows Path with a specific distro
21 let path = wslpath::wsl_to_windows_with_distro("/mnt/c/Users", "Ubuntu".to_string()).unwrap();
22 println!("WSL Path converted to Windows is {}", path);
23 // OUTPUT is
24 // WSL Path converted to Windows is C:/Users
25}