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:
parent
1e987874be
commit
edc858b97e
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user