Clarification on clonefile / copyfile support of clone directories?

The man page of copyfile sates the following:

COPYFILE_CLONE [..] Note also that there is no support for cloning directories"

COPYFILE_CLONE_FORCE [...] Note also that there is no support for cloning directories: if a directory is provided as the source, an error will be returned.

Now the man page for clonefile:

> Cloning directories with these functions is strongly discouraged.  Use copyfile(3) to clone directories instead.

--

So am I to enumerate the content of a directory build subfolders along the way in the target destination and clone each file inside individually? If I recall NSFileManager seems to clone a large directory instantly (edit actually I remembered wrong NSFileManager does not do this. Finder seems to copy instead of clone as well).

On further inspection, clonefile states that it can do this, but it is discouraged. Interesting. I wonder why.

If src names a directory, the directory hierarchy is cloned as if each item was cloned individually. However, the use of clonefile(2) to clone directory hierarchies is strongly discouraged. Use copyfile(3) instead for copying directories.

P.S. - Forgive me if I posting this in the wrong category, I couldn't find a "category" in the list of available categories on these forums that seems appropriate for this question.

I just found that Quinn wrote about this a bit here: https://developer.apple.com/forums/thread/784446

I'm still unsure why the man page for one function directs you to use another function - but that man page says cloning directories is unsupported so I'm still a bit confused about the recommendation. Is cloning directories unsupported or strongly discouraged?

Basically I have to move off NSFileManager because it doesn't provide progress and it doesn't support cancelling. But I'd like to clone when possible for speed and to save the user disk space.

That part of the copyfile man page is unfortunately somewhat poorly worded; further down it does clarify that:

 Note that recursive cloning is also supported with the COPYFILE_CLONE flag (but not the
 COPYFILE_CLONE_FORCE flag).  A recursive clone operation invokes copyfile() with
 COPYFILE_CLONE on every entry found in the source file-system object.  Because copyfile()
 does not allow the cloning of directories, a recursive clone will instead copy any directory
 it finds (while cloning its contents).  As symbolic links may point to directories, they are
 not followed during recursive clones even if the source is a symbolic link.  Additionally,
 because the COPYFILE_CLONE flag implies the COPYFILE_EXCL flag, recursive clones require a
 nonexistent destination.

So yes, you can use copyfile(3) to recursively clone directories. You should not use clonefile(2) for that purpose.

Clarification on clonefile / copyfile support of clone directories?
 
 
Q