Idea: Add an option to set the mode to fs::copy
jrose:
EDIT: …and
copyfilenow has aCOPYFILE_CLONEflag, so maybefclonefileatis a distraction anyway.
That does seem like a nice potential simplification. COPYFILE_CLONE was added in copyfile-138 which is from macOS 10.12, and 10.12 happens to be the minimum macOS supported by Rust. So the Apple fs::copy implementation could probably be replaced in its entirety with a call to copyfile.
But just to be clear, copyfile and fcopyfile are userland library functions, not syscalls, so they don't add any new abilities. In particular, fcopyfile doesn't let you clone into a file descriptor. The implementation of COPYFILE_CLONE is based on clonefileat and only works with regular copyfile. fcopyfile seems to just silently ignore the flag (even if you pass the _FORCE variant!).
Discussion in the ATmosphere