Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

hasCommonNtPrefix

Returns true if the path starts with \??\, which is indicative of an NT path but is not enough to fully distinguish between NT paths and Win32 paths, as \??\ is not actually a distinct prefix but rather the path to a special virtual folder in the Object Manager.

For example, \Device\HarddiskVolume2 and \DosDevices\C: are also NT paths but cannot be distinguished as such by their prefix.

So, inferring whether a path is an NT path or a Win32 path is usually a mistake; that information should instead be known ahead-of-time.

If T is u16, then path should be encoded as WTF-16LE.

windows.hasCommonNtPrefix
pub fn hasCommonNtPrefix(comptime T: type, path: []const T) bool

File

lib/std/os/windows.zig:3869

Code

pub fn hasCommonNtPrefix(comptime T: type, path: []const T) bool {
    // Must be exactly \??\, forward slashes are not allowed
    const expected_wtf8_prefix = "\\??\\";
    const expected_prefix = switch (T) {
        u8 => expected_wtf8_prefix,
        u16 => std.unicode.wtf8ToWtf16LeStringLiteral(expected_wtf8_prefix),
        else => @compileError("unsupported type: " ++ @typeName(T)),
    };
    return mem.startsWith(T, path, expected_prefix);
}