Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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 standard library. Public Function

hasCommonNtPrefix

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

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.

Params

  • T: type
  • path: []const T

File

os/windows.zig:3869
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
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);
}