title: copy symlink on macos using copyfile
body: <p>I am using <code>copyfile(sourceFilePath, targetFilePath, nullptr, COPYFILE_CLONE)</code> on macOS to copy symlinks (see <a href="https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/copyfile.3.html" rel="nofollow noreferrer">https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/copyfile.3.html</a>). I need to preserve the symlink and all its metadata. It works very well for file symlinks - it copies the symlink and the result is a symlink. But it does not work for directory symlinks (symlinks pointing to a directory). It is copied but the result is not preserved as symlink, it is a directory. I tried to add flag <code>COPYFILE_NOFOLLOW</code> but result is still the same. What am I doing wrong? Of is there any other way to copy symlinks pointing to directories with all their metadata?</p>