Support switching file pathes to wsl if file can not be located
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "wslpath"
|
||||
version = "1.0.0"
|
||||
version = "1.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[profile.release]
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user