feat(unstable): Add file locking APIs (#11746)

This commit adds following unstable APIs:
- Deno.flock()
- Deno.flockSync()
- Deno.funlock()
- Deno.funlockSync()
This commit is contained in:
Tilman Roeder 2021-08-24 14:21:31 +01:00 committed by GitHub
parent 46e4ba38b2
commit 93d83a84db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 283 additions and 0 deletions

View file

@ -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);

View file

@ -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);