pub fn hasCommonNtPrefix(comptime T: type, path: []const T) bool T: typepath: []const T3869
3870
3871
3872
3873
3874
3875
3876
3877
3878pub 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);
}
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\HarddiskVolume2and\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
Tisu16, thenpathshould be encoded as WTF-16LE.