#windows #realpath #unc #canonicalize #deunc

dunce

Normalize Windows paths to the most compatible format, avoiding UNC where possible

3 releases (1 stable)

✓ Uses Rust 2018 edition

new 1.0.0 Mar 14, 2019
0.1.1 Dec 5, 2017
0.1.0 Nov 22, 2017

#25 in Filesystem

Download history 390/week @ 2018-11-29 365/week @ 2018-12-06 609/week @ 2018-12-13 252/week @ 2018-12-20 394/week @ 2018-12-27 519/week @ 2019-01-03 262/week @ 2019-01-10 389/week @ 2019-01-17 346/week @ 2019-01-24 568/week @ 2019-01-31 394/week @ 2019-02-07 376/week @ 2019-02-14 402/week @ 2019-02-21 539/week @ 2019-02-28 656/week @ 2019-03-07

1,852 downloads per month
Used in 14 crates (7 directly)

CC0 license

14KB
246 lines

Dunce (de-UNC)

In Windows the regular paths (C:\foo) are supported by all programs, but have lots of bizarre restrictions for backwards compatibility with MS-DOS. There are also Windows NT UNC paths (\\?\C:\foo), which are more robust and with fewer gotchas, but are rarely supported by Windows programs. Even Microsoft's own!

This crate converts Windows UNC paths to the MS-DOS-compatible format whenever possible, but leaves UNC paths as-is when they can't be unambiguously expressed in a simpler way. This allows legacy programs to access all paths they can possibly access, and doesn't break any paths for UNC-aware programs.

In Rust the worst UNC offender is the fs::canonicalize() function. This crate provides a drop-in replacement for it that returns paths you'd expect.

On non-Windows platforms these functions leave paths unmodified, so it's safe to use them unconditionally for all platforms.


lib.rs:

Filesystem paths in Windows are a total mess. This crate normalizes paths to the most compatible (but still correct) format, so that you don't have to worry about the mess.

In Windows the regular/legacy paths (C:\foo) are supported by all programs, but have lots of bizarre restrictions for backwards compatibility with MS-DOS.

And there are Windows NT UNC paths (\\?\C:\foo), which are more robust and with fewer gotchas, but are rarely supported by Windows programs. Even Microsoft's own!

This crate converts paths to legacy format whenever possible, but leaves UNC paths as-is when they can't be unambiguously expressed in a simpler way. This allows legacy programs to access all paths they can possibly access, and UNC-aware programs to access all paths.

On non-Windows platforms these functions leave paths unmodified, so it's safe to use them unconditionally for all platforms.

Parsing is based on https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx

Project homepage.

No runtime deps