From 0f7f98795129f3f6bef51d08da9accca5e9ca9cc Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Mon, 5 Feb 2024 10:11:54 +1100 Subject: feat(unstable): `Deno.FsFile.lock[Sync]()` and `Deno.FsFile.unlock[Sync]()` (#22235) Closes #22178. --- ext/fs/30_fs.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'ext/fs/30_fs.js') diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index 9343b6ec4..aa7f345e5 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -766,6 +766,22 @@ class FsFile { futimeSync(this.#rid, atime, mtime); } + lockSync(exclusive = false) { + op_fs_flock_sync(this.#rid, exclusive); + } + + async lock(exclusive = false) { + await op_fs_flock_async(this.#rid, exclusive); + } + + unlockSync() { + op_fs_funlock_sync(this.#rid); + } + + async unlock() { + await op_fs_funlock_async(this.#rid); + } + [SymbolDispose]() { core.tryClose(this.#rid); } -- cgit v1.2.3