Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pratikpc/wsl-path-rust
Convert Windows path to WSL2 path and vice-versa
https://github.com/pratikpc/wsl-path-rust
crates crates-io rust rust-crate rust-crates rust-lang rust-library wsl wsl2
Last synced: about 1 month ago
JSON representation
Convert Windows path to WSL2 path and vice-versa
- Host: GitHub
- URL: https://github.com/pratikpc/wsl-path-rust
- Owner: pratikpc
- License: mit
- Created: 2021-09-15T15:39:41.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2023-03-04T19:51:40.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T14:51:33.226Z (about 2 months ago)
- Topics: crates, crates-io, rust, rust-crate, rust-crates, rust-lang, rust-library, wsl, wsl2
- Language: Rust
- Homepage: https://crates.io/crates/wslpath
- Size: 6.84 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WSL Path
You can use WSLPath to convert a WSL Path to a Windows Path and vice versa
---
## Implementation
Calls [wslpath](https://github.com/MicrosoftDocs/WSL/releases/tag/17046) which is a Linux based utility created by Microsoft to convert Windows and Linux paths.
We call wslpath, pass arguments, perform a conversion and return the results to the user
---
## Converting Windows Path to WSL Path
```rust
fn main() {
let path = wslpath::windows_to_wsl("C:\\Users").unwrap();
println!("Windows Path converted to WSL is {}",path);
}
```
### OUTPUT
> Windows Path converted to WSL is /mnt/c/Users----
## Converting WSL Path to Windows Path
```rust
fn main() {
let path = wslpath::wsl_to_windows("/mnt/c/Users").unwrap();
println!("WSL Path converted to Windows is {}",path);
}
```
### OUTPUT
> WSL Path converted to Windows is C:/Users----
## Converting Windows Path to WSL Path with a specific distro
In this case we are using Ubuntu
```rust
fn main() {
let path = wslpath::windows_to_wsl_with_distro("C:\\Users", "Ubuntu".to_string()).unwrap();
println!("Windows Path converted to WSL is {}", path);
}
```
### OUTPUT
> Windows Path converted to WSL is /mnt/c/Users----
## Converting WSL Path to Windows Path with a specific distro
In this case we are using Ubuntu
```rust
fn main() {
let path = wslpath::wsl_to_windows_with_distro("/mnt/c/Users", "Ubuntu".to_string()).unwrap();
println!("WSL Path converted to Windows is {}", path);
}
```
### OUTPUT
> WSL Path converted to Windows is C:/Users----