Table of Contents

Class WslProbe

Namespace
CobaltPdf.WebKit.Infrastructure.Provisioning
Assembly
CobaltPDF.WebKit.dll

Detects whether WSL (Windows Subsystem for Linux) is usable as a render backend, and exposes the bits of distro state the rest of the library needs (chosen distro name, that distro's $HOME, path translation).

All checks short-circuit on non-Windows OSes.

public static class WslProbe
Inheritance
WslProbe
Inherited Members

Methods

GetHomeAsync(string, CancellationToken)

Returns the absolute $HOME path of the default WSL user inside distro. Cached per distro for the process lifetime.

public static Task<string?> GetHomeAsync(string distro, CancellationToken cancellationToken = default)

Parameters

distro string
cancellationToken CancellationToken

Returns

Task<string>

IsAvailableAsync(CancellationToken)

Returns true when wsl.exe is on PATH, the WSL service is running, and at least one distro is installed. Caches for the process lifetime.

public static Task<bool> IsAvailableAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<bool>

ResolveDistroAsync(string?, CancellationToken)

Resolves which distro should host the render subprocess. Returns the caller's preference verbatim when supplied; otherwise the first general-purpose Linux distro reported by wsl -l -q, skipping helper distros installed by Docker Desktop / Rancher Desktop / Podman. Returns null when WSL is unavailable or no usable distro is installed.

public static Task<string?> ResolveDistroAsync(string? preferredDistro, CancellationToken cancellationToken = default)

Parameters

preferredDistro string
cancellationToken CancellationToken

Returns

Task<string>

ToUncPath(string, string)

Build the UNC view of a Linux path inside distro, e.g. (/home/x/foo, "Ubuntu")\wsl$\Ubuntu\home\x\foo. Used by C# to read/write the WSL filesystem without invoking wsl.exe.

public static string ToUncPath(string linuxPath, string distro)

Parameters

linuxPath string
distro string

Returns

string

ToWslPath(string)

Translate a Windows path to its WSL equivalent — e.g. C:\Users\foo\bar/mnt/c/Users/foo/bar. Returns the input unchanged when it does not look like a drive-rooted path.

public static string ToWslPath(string windowsPath)

Parameters

windowsPath string

Returns

string