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
Similar to RtlNtPathNameToDosPathName but does not do any heap allocation. The possible transformations are: ??\C:\Some\Path -> C:\Some\Path ??\UNC\server\share\foo -> \server\share\foo If the path does not have the NT namespace prefix, then error.NotNtPath is returned.
pubfnntToWin32Namespace(path: []constu16, out: []u16) error{ NameTooLong, NotNtPath }![]u16 {
if (path.len > PATH_MAX_WIDE) returnerror.NameTooLong;
if (!hasCommonNtPrefix(u16, path)) returnerror.NotNtPath;
vardest_index: usize = 0;
varafter_prefix = path[4..]; // after the `\??\`// The prefix \??\UNC\ means this is a UNC path, in which case the// `\??\UNC\` should be replaced by `\\` (two backslashes)constis_unc = after_prefix.len >= 4andeqlIgnoreCaseWtf16(after_prefix[0..3], std.unicode.utf8ToUtf16LeStringLiteral("UNC")) andstd.fs.path.PathType.windows.isSep(u16, after_prefix[3]);
constwin32_len = path.len - @as(usize, if (is_unc) 6else4);
if (out.len < win32_len) returnerror.NameTooLong;
if (is_unc) {
out[0] = comptimestd.mem.nativeToLittle(u16, '\\');
dest_index += 1;
// We want to include the last `\` of `\??\UNC\`after_prefix = path[7..];
}
@memmove(out[dest_index..][0..after_prefix.len], after_prefix);
returnout[0..win32_len];
}
Similar to
RtlNtPathNameToDosPathNamebut does not do any heap allocation. The possible transformations are: ??\C:\Some\Path -> C:\Some\Path ??\UNC\server\share\foo -> \server\share\foo If the path does not have the NT namespace prefix, thenerror.NotNtPathis returned.Functionality is based on the ReactOS test cases found here: https://github.com/reactos/reactos/blob/master/modules/rostests/apitests/ntdll/RtlNtPathNameToDosPathName.c
pathshould be encoded as WTF-16LE.Supports in-place modification (
pathandoutmay refer to the same slice).