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('\\', "/")
}

fn force_replace_drive_letter(mut path: String) -> String {
    let has_drive_letter = {
        let drive_letter = path.get(0..2);

        if let Some(drive_letter) = drive_letter {
            let starts_with_letter = drive_letter.chars().nth(0).unwrap_or('1').is_alphabetic();
            let has_seperator      = drive_letter.chars().nth(1).unwrap_or('x') == ':';

            starts_with_letter && has_seperator
        }

        else {
            false
        }
    };

    if has_drive_letter {
        path.replace_range(1..2, ""); // Removes : 
        if let Some(start_char) = path.get(0..1) { // Convert drive letter to lower case
            path.replace_range(0..1, start_char.to_lowercase().as_str());
        }

        if path.len() == 3 {
            path.push('/');
        }
        
        path.insert_str(0, "/mnt/");
    }

    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
}