winpath

package
v0.107.39 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package winpath maps the Win32 file namespace spelling of a local path to the ordinary one, so that path boundaries and permission rules compare one form.

\\?\D:\a\b.png names the same file as D:\a\b.png; it only tells Windows to skip path normalization. Tools such as Rust's fs::canonicalize and screenshot helpers print it, and models copy it. Go treats \\?\D: and D: as different volumes, so filepath.Rel between the two spellings fails.

Index

Constants

This section is empty.

Variables

View Source
var ErrNamespace = errors.New(`unsupported Windows path namespace; use an ordinary path such as D:\dir\file or \\server\share\file`)

ErrNamespace reports a Windows namespace spelling (\\.\, \??\, volume GUIDs, GLOBALROOT, ...) or an extended path that has no ordinary equivalent.

Functions

func Normalize

func Normalize(p string) (string, error)

Normalize returns the ordinary spelling of an extended local path: \\?\x:\dir becomes X:\dir and \\?\UNC\server\share\dir becomes \\server\share\dir. Paths without a namespace prefix, and every path off Windows, come back unchanged. Device namespaces, volume paths, and extended paths whose meaning would change once Windows normalizes them (".", "..", "/", empty components, trailing dots or spaces, ":" streams, reserved device names) return ErrNamespace. Long paths need no prefix: the os package adds one itself.

func Simplify

func Simplify(p string) string

Simplify is Normalize for paths the backend already trusts, such as configured roots: a spelling Normalize refuses is returned unchanged.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL