Crates.io | realpath-rs |
lib.rs | realpath-rs |
version | 0.2.0 |
source | src |
created_at | 2023-03-30 07:26:52.905501 |
updated_at | 2023-08-28 05:42:22.089569 |
description | A cross-platform Rust equivalent of python3's `os.path.realpath` |
homepage | |
repository | https://www.github.com/loggerheads-with-binary/realpath-rs |
max_upload_size | |
id | 824703 |
size | 7,678 |
A cross-platform Rust equivalent of python3's os.path.realpath
use realpath::*;
use std::path::PathBuf;
let src = PathBuf::from("Cargo.toml");
let dest : PathBuf = realpath(&src)?;
println!("{} -> {}", src, dest.display()); //Returns Cargo.toml -> /path/to/Cargo.toml on linux and Drive:\path\to\Cargo.toml on windows
//For windows
let src = PathBuf::from(r"Doge.exe");
let dest : PathBuf = realpath_win(&src , false)?;
println!("{}" , dest.display()); //Returns \\?\Drive:\path\to\Doge.exe
let dest : PathBuf = realpath_win(&src , true)?;
println!("{}" , dest.display()); //Returns Drive:\path\to\Doge.exe
//Inner functionality
let dest = realpath_og(&src)?;
println!("{}" , dest.display()); //Returns /path/to/Cargo.toml on linux and \\?\Drive:\path\to\Cargo.toml on windows