Return the entries plus a bool indicating EOF.
(fd: wasip1::Fd, cookie: wasip1::Dircookie)
| 56 | |
| 57 | /// Return the entries plus a bool indicating EOF. |
| 58 | unsafe fn exec_fd_readdir(fd: wasip1::Fd, cookie: wasip1::Dircookie) -> (Vec<DirEntry>, bool) { |
| 59 | let mut buf: [u8; BUF_LEN] = [0; BUF_LEN]; |
| 60 | let bufused = |
| 61 | wasip1::fd_readdir(fd, buf.as_mut_ptr(), BUF_LEN, cookie).expect("failed fd_readdir"); |
| 62 | assert!(bufused <= BUF_LEN); |
| 63 | |
| 64 | let sl = slice::from_raw_parts(buf.as_ptr(), bufused); |
| 65 | let dirs: Vec<_> = ReadDir::from_slice(sl).collect(); |
| 66 | let eof = bufused < BUF_LEN; |
| 67 | (dirs, eof) |
| 68 | } |
| 69 | |
| 70 | unsafe fn assert_empty_dir(dir_fd: wasip1::Fd) { |
| 71 | let stat = wasip1::fd_filestat_get(dir_fd).expect("failed filestat"); |