Support switching file pathes to wsl if file can not be located

This commit is contained in:
2024-05-06 19:53:57 +02:00
parent 3e7ead0e7d
commit a9444a19f2
4 changed files with 33 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "wslpath"
version = "1.0.0"
version = "1.1.0"
edition = "2021"
[profile.release]

View File

@@ -2,12 +2,15 @@ pub fn convert(path: String) -> String {
replace_drive_letter(convert_slashes(path))
}
pub fn force_convert(path: String) -> String {
force_replace_drive_letter(convert_slashes(path))
}
fn convert_slashes(path: String) -> String {
path.replace('\\', "/")
}
#[cfg(target_os = "windows")]
fn replace_drive_letter(mut path: String) -> String {
fn force_replace_drive_letter(mut path: String) -> String {
let has_drive_letter = {
let drive_letter = path.get(0..2);
@@ -39,6 +42,11 @@ fn replace_drive_letter(mut path: String) -> String {
path
}
#[cfg(target_os = "windows")]
fn replace_drive_letter(path: String) -> String {
force_replace_drive_letter(path)
}
#[cfg(not(target_os = "windows"))]
fn replace_drive_letter(path: String) -> String {
path