chipsenkbeil / typed-path

Provides typed variants of Path and PathBuf for Unix and Windows
38 stars 6 forks source link

Skip normalization for verbatim paths #2

Closed chipsenkbeil closed 2 years ago

chipsenkbeil commented 2 years ago

From https://docs.microsoft.com/en-us/dotnet/standard/io/file-path-formats#skip-normalization:

Normally, any path passed to a Windows API is (effectively) passed to the GetFullPathName function and normalized. There is one important exception: a device path that begins with a question mark instead of a period. Unless the path starts exactly with \\?\ (note the use of the canonical backslash), it is normalized.

Why would you want to skip normalization? There are three major reasons:

To get access to paths that are normally unavailable but are legal. A file or directory called hidden., for example, is impossible to access in any other way.

To improve performance by skipping normalization if you've already normalized.

On .NET Framework only, to skip the MAX_PATH check for path length to allow for paths that are greater than 259 characters. > Most APIs allow this, with some exceptions.

chipsenkbeil commented 2 years ago

Also see https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#fully-qualified-vs-relative-paths

chipsenkbeil commented 2 years ago

Finally accomplished an initial version of this with some minor discrepancies with Rust's stdlib implementation.