diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-25 03:26:49 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 17:26:49 +0100 |
commit | f5097d9d3b62f7dc8e29e85e12f6a6f2858addbf (patch) | |
tree | 63a828e08571bf8bbde3e341e48392c91bf645fe /ext | |
parent | 6b5c9764ac8087d035ef6a3f2542bd089957035e (diff) |
feat: `Deno.FsFile.{utime,utimeSync}()` and deprecate `Deno.{futime,futimeSync}` (#22070)
For removal in Deno v2.
---------
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fs/30_fs.js | 8 | ||||
-rw-r--r-- | ext/node/polyfills/_fs/_fs_futimes.ts | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index 810089950..2136d88f6 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -752,6 +752,14 @@ class FsFile { op_fs_fsync_sync(this.#rid); } + async utime(atime, mtime) { + await futime(this.#rid, atime, mtime); + } + + utimeSync(atime, mtime) { + futimeSync(this.#rid, atime, mtime); + } + [SymbolDispose]() { core.tryClose(this.#rid); } diff --git a/ext/node/polyfills/_fs/_fs_futimes.ts b/ext/node/polyfills/_fs/_fs_futimes.ts index 8a29db26b..9bd41e114 100644 --- a/ext/node/polyfills/_fs/_fs_futimes.ts +++ b/ext/node/polyfills/_fs/_fs_futimes.ts @@ -4,6 +4,7 @@ // deno-lint-ignore-file prefer-primordials import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts"; +import { FsFile } from "ext:deno_fs/30_fs.js"; function getValidTime( time: number | string | Date, @@ -38,7 +39,8 @@ export function futimes( atime = getValidTime(atime, "atime"); mtime = getValidTime(mtime, "mtime"); - Deno.futime(fd, atime, mtime).then(() => callback(null), callback); + // TODO(@littledivy): Treat `fd` as real file descriptor. + new FsFile(fd).utime(atime, mtime).then(() => callback(null), callback); } export function futimesSync( @@ -49,5 +51,6 @@ export function futimesSync( atime = getValidTime(atime, "atime"); mtime = getValidTime(mtime, "mtime"); - Deno.futimeSync(fd, atime, mtime); + // TODO(@littledivy): Treat `fd` as real file descriptor. + new FsFile(fd).utimeSync(atime, mtime); } |