Using the COPYFILE_EXCL flag with the copyfile function works as expected when copying files (the copy fails if a file at the destination path already exists).
But when copying a directory, if you specify this flag and the destination already exists copyfile will just copy the directory inside of the already existing directory, instead of failing with an error. Does anyone know why? It seems kind of peculiar to copy a directory to a location not specified by the caller?
As far as I can tell the only way to get the behavior to work the way I'd expect is to look before you leap? So I'd have to do:
if (destinationURLIsDirectory && [destinationURL checkResourceIsReachableAndReturnError:nil])
{
NSLog(@"fail...destination already exists..don't start copyfile");
return;
}