fs: refactor promises version of lchown and lchmod

Check for platform support first to save a level of indentation.

PR-URL: https://github.com/nodejs/node/pull/20551
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
This commit is contained in:
cjihrig 2018-05-05 19:42:35 -04:00
parent 1e987874be
commit edc858b97e
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -378,21 +378,19 @@ async function chmod(path, mode) {
}
async function lchmod(path, mode) {
if (O_SYMLINK !== undefined) {
const fd = await open(path,
O_WRONLY | O_SYMLINK);
return fchmod(fd, mode).finally(fd.close.bind(fd));
}
throw new ERR_METHOD_NOT_IMPLEMENTED();
if (O_SYMLINK === undefined)
throw new ERR_METHOD_NOT_IMPLEMENTED();
const fd = await open(path, O_WRONLY | O_SYMLINK);
return fchmod(fd, mode).finally(fd.close.bind(fd));
}
async function lchown(path, uid, gid) {
if (O_SYMLINK !== undefined) {
const fd = await open(path,
O_WRONLY | O_SYMLINK);
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
}
throw new ERR_METHOD_NOT_IMPLEMENTED();
if (O_SYMLINK === undefined)
throw new ERR_METHOD_NOT_IMPLEMENTED();
const fd = await open(path, O_WRONLY | O_SYMLINK);
return fchown(fd, uid, gid).finally(fd.close.bind(fd));
}
async function fchown(handle, uid, gid) {