diff --git a/doc/api/fs.md b/doc/api/fs.md index d705a78f990647..c9adb5b16af001 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1175,8 +1175,18 @@ operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination. `flags` is an optional integer that specifies the behavior -of the copy operation. The only supported flag is `fs.constants.COPYFILE_EXCL`, -which causes the copy operation to fail if `dest` already exists. +of the copy operation. It is possible to create a mask consisting of the bitwise +OR of two or more values (e.g. +`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + +* `fs.constants.COPYFILE_EXCL` - The copy operation will fail if `dest` already +exists. +* `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a +copy-on-write reflink. If the platform does not support copy-on-write, then a +fallback copy mechanism is used. +* `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to +create a copy-on-write reflink. If the platform does not support copy-on-write, +then the operation will fail. Example: @@ -1216,8 +1226,18 @@ atomicity of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination. `flags` is an optional integer that specifies the behavior -of the copy operation. The only supported flag is `fs.constants.COPYFILE_EXCL`, -which causes the copy operation to fail if `dest` already exists. +of the copy operation. It is possible to create a mask consisting of the bitwise +OR of two or more values (e.g. +`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + +* `fs.constants.COPYFILE_EXCL` - The copy operation will fail if `dest` already +exists. +* `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a +copy-on-write reflink. If the platform does not support copy-on-write, then a +fallback copy mechanism is used. +* `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to +create a copy-on-write reflink. If the platform does not support copy-on-write, +then the operation will fail. Example: @@ -3814,8 +3834,18 @@ error occurs after the destination file has been opened for writing, Node.js will attempt to remove the destination. `flags` is an optional integer that specifies the behavior -of the copy operation. The only supported flag is `fs.constants.COPYFILE_EXCL`, -which causes the copy operation to fail if `dest` already exists. +of the copy operation. It is possible to create a mask consisting of the bitwise +OR of two or more values (e.g. +`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`). + +* `fs.constants.COPYFILE_EXCL` - The copy operation will fail if `dest` already +exists. +* `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a +copy-on-write reflink. If the platform does not support copy-on-write, then a +fallback copy mechanism is used. +* `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to +create a copy-on-write reflink. If the platform does not support copy-on-write, +then the operation will fail. Example: @@ -4449,6 +4479,34 @@ The following constants are meant for use with [`fs.access()`][]. +### File Copy Constants + +The following constants are meant for use with [`fs.copyFile()`][]. + +
Constant | +Description | +
---|---|
COPYFILE_EXCL |
+ If present, the copy operation will fail with an error if the + destination path already exists. | +
COPYFILE_FICLONE |
+ If present, the copy operation will attempt to create a + copy-on-write reflink. If the underlying platform does not support + copy-on-write, then a fallback copy mechanism is used. | +
COPYFILE_FICLONE_FORCE |
+ If present, the copy operation will attempt to create a + copy-on-write reflink. If the underlying platform does not support + copy-on-write, then the operation will fail with an error. | +