FD_READDIR

Read directory entries from a directory. When successful, the contents of the output buffer consist of a sequence of directory entries. Each directory entry consists of a dirent object, followed by dirent::d_namlen bytes holding the name of the directory entry.

This function fills the output buffer as much as possible, potentially truncating the last directory entry. This allows the caller to grow its read buffer size in case it's too small to fit a single large directory entry, or skip the oversized directory entry.

Entries for the special . and .. directory entries are included in the sequence.

(@interface func (export "fd_readdir")
(param $fd $fd)
;;; The buffer where directory entries are stored
(param $buf (@witx pointer u8))
(param $buf_len $size)
;;; The location within the directory to start reading
(param $cookie $dircookie)
;;; The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the
;;; directory has been reached.
(result $error (expected $size (error $errno)))
)