Skip to content

Commit

Permalink
Implement sync and datasync on files and directories.
Browse files Browse the repository at this point in the history
On Windows, there doesn't appear to be a way to sync a directory, to
ensure that the directory entry for a file is sync'd. So for now, just
silently succeed. I've opened WebAssembly/wasi-filesystem#79 to track
this at the spec level.
  • Loading branch information
sunfishcode committed Jan 18, 2023
1 parent 6a41baf commit 902ca94
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -847,14 +847,14 @@ pub unsafe extern "C" fn fd_readdir(
let dir = state.get_dir(fd)?;
iter = DirEntryIterator {
state,
cookie: 0,
cookie: wasi::DIRCOOKIE_START,
use_cache: false,
stream: DirEntryStream(wasi_filesystem::readdir(dir.fd)?),
};

// Skip to the entry that is requested by the `cookie`
// parameter.
for _ in 0..cookie {
for _ in wasi::DIRCOOKIE_START..cookie {
match iter.next() {
Some(Ok(_)) => {}
Some(Err(e)) => return Err(e),
Expand Down Expand Up @@ -2288,7 +2288,7 @@ impl State {
dirent_cache: DirentCache {
stream: Cell::new(None),
for_fd: Cell::new(0),
cookie: Cell::new(0),
cookie: Cell::new(wasi::DIRCOOKIE_START),
cached_dirent: Cell::new(wasi::Dirent {
d_next: 0,
d_ino: 0,
Expand Down

0 comments on commit 902ca94

Please sign in to comment.