4 releases
0.2.0 | Aug 28, 2023 |
---|---|
0.1.6 | Apr 15, 2023 |
0.1.5 | Apr 15, 2023 |
0.1.0 | Mar 30, 2023 |
#1369 in Filesystem
26 downloads per month
Used in utrans
7KB
78 lines
realpath-rs
A cross-platform Rust equivalent of python3's os.path.realpath
Usage
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
lib.rs
:
Usage
#no_run
use crate::realpath::realpath;
use std::path::PathBuf;
let src = PathBuf::from("Cargo.toml");
let dest : PathBuf = realpath(&src)?;
println!("{} -> {}", src.display(), dest.display());
Dependencies
~125KB