silk.platform.windows.path.
Windows host paths represented in an explicit machine-wide path namespace.
When to use#
Use WindowsPath at compiler and process host boundaries. Drive paths map to /C:/...
and UNC paths to /UNC/server/share/.... These names are separate from a confined
OsFileSystem provider's /, which always denotes that provider's chosen root.
Import as WindowsPath with import silk.platform.windows.path { WindowsPath }.
Public declarations: 1.
WindowsPath#
pub struct WindowsPathConversion between absolute Windows host names and machine-wide portable paths.
Details#
Case and canonical WTF-8 bytes are preserved. Converting a path does not access the host, resolve links, or assert confinement. Relative paths and device namespaces are refused.
Implementation WindowsPath#
impl WindowsPathAssociated function parent#
pub effect fn parent(path: &Path) -> Option<Path> ! OutOfMemoryError ? &mut AllocatorReturns the parent without crossing a drive or UNC share root.
A recognized volume root has no parent; other paths use the portable Path.parent rule.
Associated function resolve#
pub effect fn resolve(base: &Path, argument: string) -> Path
! FileError | OutOfMemoryError ? &mut AllocatorResolves a text host path against an absolute machine path, without accessing files.
Details#
Both separators are accepted. Absolute drive, UNC, and machine paths select their volume;
a single leading separator selects the base volume. Relative paths stay on the base volume.
. and .. are normalized, and a parent component cannot cross the volume root.
Errors#
FileErrorwithInvalidPathfor malformed paths, device names, drive-relative names, empty interior components, or a parent component above the volume root.OutOfMemoryErrorif the path cannot be allocated.
Associated function resolveBytes#
pub effect fn resolveBytes(base: &Path, argument: &[u8]) -> Path
! FileError | OutOfMemoryError ? &mut AllocatorResolves canonical WTF-8 host bytes against an absolute machine path.
Details#
Accepts absolute drive, UNC, machine, and relative paths. Both separators are accepted
except inside an extended \\\\?\\ name, where only backslashes are separators.
Case and lone surrogates are preserved. . and .. are normalized within one volume.
A single leading separator selects the base volume; drive-relative names are refused.
Errors#
FileErrorwithInvalidPathfor malformed WTF-8, NUL, device paths, empty interior components, invalid volume names, or a parent component above the volume root.OutOfMemoryErrorif the result cannot be allocated.
Associated function fromNative#
pub effect fn fromNative(value: string) -> Path ! FileError | OutOfMemoryError ? &mut AllocatorConverts an absolute Windows text path to /C:/... or /UNC/server/share/....
Errors#
FileErrorwithInvalidPathfor relative paths, device namespaces, or non-normalized components.OutOfMemoryErrorif the path cannot be allocated.
Associated function fromNativeBytes#
pub effect fn fromNativeBytes(value: &[u8]) -> Path ! FileError | OutOfMemoryError ? &mut AllocatorConverts canonical WTF-8 Windows host bytes to a machine-wide portable path.
Details#
Accepts absolute drive and UNC names, including \\?\C:\... and \\?\UNC\server\share\....
Normal names accept either separator. Extended names accept only backslashes. A trailing
separator is removed. Case, trailing component dots/spaces, and lone surrogates are preserved.
A drive root is represented by /C:, and a share root by /UNC/server/share.
Errors#
FileErrorwithInvalidPathfor malformed WTF-8, NUL, relative/device paths, empty components,.or.., or colons outside the drive prefix.OutOfMemoryErrorif the path cannot be allocated.
Associated function toNativeBytes#
pub effect fn toNativeBytes(path: &Path) -> Bytes ! FileError | OutOfMemoryError ? &mut AllocatorReturns an extended Windows host name as canonical WTF-8, without a NUL terminator.
Details#
/C:/... becomes \\?\C:\...; /UNC/server/share/... becomes \\?\UNC\server\share\....
The extended prefix preserves trailing dots/spaces and avoids Win32's legacy path-length
normalization. Some tools, such as Git, refuse extended names in their arguments; give those
the normal name WindowsPath.toArgumentBytes returns.
Errors#
FileErrorwithInvalidPathif the path lacks a volume, has invalid WTF-8, or contains a backslash or a colon outside its drive prefix.OutOfMemoryErrorif the host name cannot be allocated.
Associated function toArgumentBytes#
pub effect fn toArgumentBytes(path: &Path) -> Bytes ! FileError | OutOfMemoryError ? &mut AllocatorReturns the normal Win32 name of path, as canonical WTF-8 without a NUL terminator, for a
process argument or an environment value.
Details#
/C:/... becomes C:\... and /UNC/server/share/... becomes \\server\share\..., the
spelling a user types. Some tools, such as Git, refuse the extended
\\?\ names WindowsPath.toNativeBytes returns. Win32 rewrites some normal names, so a
path that would name another file is refused instead: a component that ends in a dot or a
space, or a reserved device name such as NUL or COM1.txt. A name longer than 259 units
works only with a tool that accepts long paths.
Errors#
FileErrorwithInvalidPathif the path lacks a volume, has invalid WTF-8, contains a backslash or a colon outside its drive prefix, or has a component Win32 would rewrite.OutOfMemoryErrorif the host name cannot be allocated.
Category: Windows platform.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.