Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/55171
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
UV error code needs to be negative integer so it can be mapped
correctly. The filesystem error are positive integer, so we need to
handle it before throwing.
Co-authored-by: Jake Yuesong Li <jake.yuesong@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/54906
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
`fs.copyFile()` supports copy-on-write operation
if the underlying platform supports it by passing a mode flag.
This behavior was added in
a16d88d9e9.
This patch adds `mode` flag to `fs.cp()`, `fs.cpSync()`,
and `fsPromises.cp()` to allow to change their behaviors
to copy files.
This test case is based on the test case that was introduced
when we add `fs.constants.COPYFILE_FICLONE`.
a16d88d9e9.
This test strategy is:
- If the platform supports copy-on-write operation,
check whether the destination is expected
- Otherwise, the operation will fail
and check whether the failure error information is expected.
Fixes: https://github.com/nodejs/node/issues/47080
PR-URL: https://github.com/nodejs/node/pull/47084
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>