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 from the file at the given offset without updating the file cursor. This acts like a stateless version of Seek + Read
fd_pread (
fd: i32The file descriptor of the file to read fromiovs: i32A pointer to an array of iovec structures describing the buffers where the data will be storediovs_len: i32The number of vectors iovecs in the iovs arrayoffset: i32The file cursor indicating the starting position from which data will be readnread: i32A pointer to store the number of bytes read
) =>
error: i32 

The fd_pread() function is used to read data from a file identified by the provided file descriptor (fd) at a specified offset (offset). Unlike regular reading operations, fd_pread() does not update the file cursor, making it a stateless operation. The function reads data into the provided buffers (iovs) and returns the number of bytes read.

In POSIX systems, file reading operations typically involve updating the file cursor, which determines the next position from which data will be read. However, fd_pread() allows reading data from a specific offset without modifying the file cursor's position. This can be useful in scenarios where applications need to read data from a file at a specific location without altering the cursor's state.

Note

The fd_pread() function allows reading data from a file at a specified offset without updating the file cursor. It provides a stateless alternative to the traditional Seek + Read operations. The function takes the file descriptor, an array of buffers to store the data, the offset indicating the starting position, and a pointer to store the number of bytes read.

Read More