diff options
author | Tilman Roeder <dyed.green.info@gmail.com> | 2021-08-24 14:21:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-24 15:21:31 +0200 |
commit | 93d83a84dbe1f6ecf93b596f88bc85ba378fa986 (patch) | |
tree | 8f9165f29064b0eb6d34661577877ebc2a3e37b3 /runtime/js | |
parent | 46e4ba38b2b1ccee8d3b4f04be1a2cc0b42cd52a (diff) |
feat(unstable): Add file locking APIs (#11746)
This commit adds following unstable APIs:
- Deno.flock()
- Deno.flockSync()
- Deno.funlock()
- Deno.funlockSync()
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/30_fs.js | 20 | ||||
-rw-r--r-- | runtime/js/90_deno_ns.js | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/runtime/js/30_fs.js b/runtime/js/30_fs.js index e45cda321..feb9f8f54 100644 --- a/runtime/js/30_fs.js +++ b/runtime/js/30_fs.js @@ -385,6 +385,22 @@ await core.opAsync("op_fsync_async", rid); } + function flockSync(rid, exclusive) { + core.opSync("op_flock_sync", rid, exclusive === true); + } + + async function flock(rid, exclusive) { + await core.opAsync("op_flock_async", rid, exclusive === true); + } + + function funlockSync(rid) { + core.opSync("op_funlock_sync", rid); + } + + async function funlock(rid) { + await core.opAsync("op_funlock_async", rid); + } + window.__bootstrap.fs = { cwd, chdir, @@ -433,5 +449,9 @@ fdatasyncSync, fsync, fsyncSync, + flock, + flockSync, + funlock, + funlockSync, }; })(this); diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 796361d7a..71c8bd0f0 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -136,5 +136,9 @@ createHttpClient: __bootstrap.fetch.createHttpClient, http: __bootstrap.http, dlopen: __bootstrap.ffi.dlopen, + flock: __bootstrap.fs.flock, + flockSync: __bootstrap.fs.flockSync, + funlock: __bootstrap.fs.funlock, + funlockSync: __bootstrap.fs.funlockSync, }; })(this); |