Index wasi args_get args_sizes_get clock_res_get clock_time_get environ_get environ_sizes_get fd_advise fd_allocate fd_close fd_datasync fd_fdstat_get fd_fdstat_set_flags fd_fdstat_set_rights fd_filestat_get fd_filestat_set_size fd_filestat_set_times fd_pread fd_prestat_dir_name fd_prestat_get fd_pwrite fd_read fd_readdir fd_renumber fd_seek fd_sync fd_tell fd_write file_stat_flags filestat iovec lookup_flags path_create_directory path_filestat_get path_filestat_set_times path_link path_open path_readlink path_remove_directory path_rename path_symlink path_unlink_file poll_oneoff proc_exit proc_raise random_get sched_yield sock_accept sock_recv sock_send sock_shutdown
Read data from a directory specified by the file descriptor
fd_readdir (
fd: i32The file descriptor of the directory to read frombuf: i32A pointer to the buffer where directory entries will be storedbuf_len: i32The length of the buffer in bytescookie: i32The directory cookie indicating the position to start reading frombufused: i32A pointer to store the number of bytes stored in the buffer
) =>
error: i32 

The fd_readdir() function reads directory entries from a directory identified by the provided file descriptor (fd). It stores the directory entries in the buffer specified by buf and returns the number of bytes stored in the buffer via the bufused pointer.

Note

The fd_readdir() function reads directory entries from a directory identified by the file descriptor fd. It takes the file descriptor, a buffer where the directory entries will be stored, the length of the buffer in bytes, the directory cookie indicating the position to start reading from, and a pointer to store the number of bytes stored in the buffer.

The function reads the directory entries and stores them in the buffer according to the specified format. The bufused pointer will be updated with the number of bytes stored in the buffer. If the entire directory has been read and there is no more data to read, the function will indicate this by storing a value less than buf_len in bufused.

The function returns an Errno value to indicate the success or failure of the operation. If the directory entries are successfully read and stored in the buffer, it returns Errno::Success. Otherwise, it returns an appropriate error code.

Read More