From e202df8e4b1f5aee1c9b04996807bae942723a2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Thu, 14 May 2020 11:54:00 +0200 Subject: [PATCH] fs: implement lutimes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33399 Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Jiawen Geng Reviewed-By: Juan José Arboleda --- doc/api/fs.md | 51 +++++++++++++++++++++++ lib/fs.js | 24 +++++++++++ lib/internal/fs/promises.js | 9 ++++ src/node_file.cc | 30 ++++++++++++++ test/parallel/test-fs-utimes.js | 73 ++++++++++++++++++++------------- 5 files changed, 159 insertions(+), 28 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 16474b79059465..e84d8f4c9172e6 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2396,6 +2396,38 @@ changes: Synchronous lchown(2). Returns `undefined`. +## `fs.lutimes(path, atime, mtime, callback)` + + +* `path` {string|Buffer|URL} +* `atime` {number|string|Date} +* `mtime` {number|string|Date} +* `callback` {Function} + * `err` {Error} + +Changes the access and modification times of a file in the same way as +[`fs.utimes()`][], with the difference that if the path refers to a symbolic +link, then the link is not dereferenced: instead, the timestamps of the +symbolic link itself are changed. + +No arguments other than a possible exception are given to the completion +callback. + +## `fs.lutimesSync(path, atime, mtime)` + + +* `path` {string|Buffer|URL} +* `atime` {number|string|Date} +* `mtime` {number|string|Date} + +Change the file system timestamps of the symbolic link referenced by `path`. +Returns `undefined`, or throws an exception when parameters are incorrect or +the operation fails. This is the synchronous version of [`fs.lutimes()`][]. + ## `fs.link(existingPath, newPath, callback)` + +* `path` {string|Buffer|URL} +* `atime` {number|string|Date} +* `mtime` {number|string|Date} +* Returns: {Promise} + +Changes the access and modification times of a file in the same way as +[`fsPromises.utimes()`][], with the difference that if the path refers to a +symbolic link, then the link is not dereferenced: instead, the timestamps of +the symbolic link itself are changed. + +Upon success, the `Promise` is resolved without arguments. + ### `fsPromises.link(existingPath, newPath)`