Skip to main content

windows_to_wsl

Function windows_to_wsl 

Source
pub fn windows_to_wsl(path: &str) -> String
Expand description

Translate a Windows-style path to a WSL2 Linux path.

§Rules

  • Drive letter paths: C:\path → /mnt/c/path
  • Drive letter only: C: → /mnt/c
  • UNC WSL paths: \\wsl$\Distro\path → /path
  • Forward slashes are normalized to forward slashes
  • Drive letter is lowercased

§Examples

use rusty_stack::platform::path_bridge::windows_to_wsl;

assert_eq!(windows_to_wsl(r"C:\Users\alice\mlstack"), "/mnt/c/Users/alice/mlstack");
assert_eq!(windows_to_wsl(r"\\wsl$\Ubuntu\home\alice\.mlstack"), "/home/alice/.mlstack");