Skip to main content

Module path_bridge

Module path_bridge 

Source
Expand description

Windows ↔ WSL2 path translation bridge.

Provides bidirectional path translation between Windows and WSL2 path formats, handling drive letters, UNC paths, Unicode, and spaces.

§Path Translation Rules

Windows → WSL2:

  • C:\Users\alice → /mnt/c/Users/alice
  • D:\data\file.txt → /mnt/d/data/file.txt
  • \\wsl$\Ubuntu\home\alice → /home/alice (UNC WSL path)

WSL2 → Windows:

  • /home/alice → \\wsl$\Ubuntu\home\alice
  • /mnt/c/Users → C:\Users

§Unicode and Spaces

All translations preserve Unicode characters and handle spaces correctly. Round-trip translation produces the original path for supported formats.

Structs§

PathTranslation
Result of a path translation attempt.

Enums§

TranslationDirection
Direction of path translation.

Constants§

DEFAULT_WSL_DISTRO
Default WSL distribution name used for WSL2 → Windows translation.

Functions§

is_windows_path
Check if a path looks like a Windows path.
translate_path
Translate a path auto-detecting direction.
windows_to_wsl
Translate a Windows-style path to a WSL2 Linux path.
wsl_to_windows
Translate a WSL2 Linux path to a Windows-style path.
wsl_to_windows_with_distro
Translate a WSL2 Linux path to a Windows path with a specified distro name.