Browse the docs

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#

silk
pub struct WindowsPath

Conversion 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#

silk
impl WindowsPath

Associated function parent#

silk
pub effect fn parent(path: &Path) -> Option<Path> ! OutOfMemoryError ? &mut Allocator

Returns 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#

silk
pub effect fn resolve(base: &Path, argument: string) -> Path
  ! FileError | OutOfMemoryError ? &mut Allocator

Resolves 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#

  • FileError with InvalidPath for malformed paths, device names, drive-relative names, empty interior components, or a parent component above the volume root.

  • OutOfMemoryError if the path cannot be allocated.

Associated function resolveBytes#

silk
pub effect fn resolveBytes(base: &Path, argument: &[u8]) -> Path
  ! FileError | OutOfMemoryError ? &mut Allocator

Resolves 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#

  • FileError with InvalidPath for malformed WTF-8, NUL, device paths, empty interior components, invalid volume names, or a parent component above the volume root.

  • OutOfMemoryError if the result cannot be allocated.

Associated function fromNative#

silk
pub effect fn fromNative(value: string) -> Path ! FileError | OutOfMemoryError ? &mut Allocator

Converts an absolute Windows text path to /C:/... or /UNC/server/share/....

Errors#

  • FileError with InvalidPath for relative paths, device namespaces, or non-normalized components.

  • OutOfMemoryError if the path cannot be allocated.

Associated function fromNativeBytes#

silk
pub effect fn fromNativeBytes(value: &[u8]) -> Path ! FileError | OutOfMemoryError ? &mut Allocator

Converts 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#

  • FileError with InvalidPath for malformed WTF-8, NUL, relative/device paths, empty components, . or .., or colons outside the drive prefix.

  • OutOfMemoryError if the path cannot be allocated.

Associated function toNativeBytes#

silk
pub effect fn toNativeBytes(path: &Path) -> Bytes ! FileError | OutOfMemoryError ? &mut Allocator

Returns 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. Other arguments to a process must not be passed through this conversion.

Errors#

  • FileError with InvalidPath if the path lacks a volume, has invalid WTF-8, or contains a backslash or a colon outside its drive prefix.

  • OutOfMemoryError if 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.

View the source of this page