summaryrefslogtreecommitdiff
path: root/std/wasi/snapshot_preview1.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-06-30 05:45:39 +0800
committerGitHub <noreply@github.com>2020-06-29 17:45:39 -0400
commitcb16439e85ed4f5de7b7017e1a994780ff670e37 (patch)
treea671f36f170007ceaa84157ae80504846a18aa14 /std/wasi/snapshot_preview1.ts
parenta19d6a2613b65771748cee97c620c04a62e8a6e4 (diff)
feat(std/wasi): implement fd_sync (#6560)
Diffstat (limited to 'std/wasi/snapshot_preview1.ts')
-rw-r--r--std/wasi/snapshot_preview1.ts13
1 files changed, 12 insertions, 1 deletions
diff --git a/std/wasi/snapshot_preview1.ts b/std/wasi/snapshot_preview1.ts
index 4fe4e02b4..e42d7eec2 100644
--- a/std/wasi/snapshot_preview1.ts
+++ b/std/wasi/snapshot_preview1.ts
@@ -842,7 +842,18 @@ export default class Module {
},
fd_sync: (fd: number): number => {
- return ERRNO_NOSYS;
+ const entry = this.fds[fd];
+ if (!entry) {
+ return ERRNO_BADF;
+ }
+
+ try {
+ Deno.fsyncSync(entry.handle.rid);
+ } catch (err) {
+ return errno(err);
+ }
+
+ return ERRNO_SUCCESS;
},
fd_tell: (fd: number, offset_out: number): number => {