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
pubfncreateFileDevicePath(
self: *constDevicePath,
allocator: Allocator,
path: []constu16,
) CreateFileDevicePathError!*constDevicePath {
constpath_size = self.size();
// 2 * (path.len + 1) for the path and its null terminator, which are u16s// DevicePath for the extra node before the endvarbuf = tryallocator.alloc(u8, path_size + 2 * (path.len + 1) + @sizeOf(DevicePath));
@memcpy(buf[0..path_size], @as([*]constu8, @ptrCast(self))[0..path_size]);
// Pointer to the copy of the end node of the current chain, which is - 4 from the buffer// as the end node itself is 4 bytes (type: u8 + subtype: u8 + length: u16).varnew = @as(*uefi.DevicePath.Media.FilePathDevicePath, @ptrCast(buf.ptr + path_size - 4));
new.type = .media;
new.subtype = .file_path;
new.length = @sizeOf(uefi.DevicePath.Media.FilePathDevicePath) + 2 * (@as(u16, @intCast(path.len)) + 1);
// The same as new.getPath(), but not const as we're filling it in.varptr = @as([*:0]align(1) u16, @ptrCast(@as([*]u8, @ptrCast(new)) + @sizeOf(uefi.DevicePath.Media.FilePathDevicePath)));
for (path, 0..) |s, i|
ptr[i] = s;
ptr[path.len] = 0;
varend = @as(*uefi.DevicePath.End.EndEntireDevicePath, @ptrCast(@constCast(@as(*DevicePath, @ptrCast(new)).next().?)));
end.type = .end;
end.subtype = .end_entire;
end.length = @sizeOf(uefi.DevicePath.End.EndEntireDevicePath);
return@as(*DevicePath, @ptrCast(buf.ptr));
}
Creates a file device path from the existing device path and a file path.