Copyfile function in Mac OS X

I'm working on a program that copies files and folders from point a to point b, it's pretty straightforward for the most part. I decided to use the copyfile function to do the actual copy as it handles all the metadata. For some reason, there are many files that it cannot copy, even if I run it as root. Example file that cannot be copied/usr/share/emacs/22.1/etc/BABYL

I don't know why he does this. The file itself is good, I can go to it in the Finder and copy and paste it like any other regular file. Are there any permission issues that I am missing? This seems to be done only for system files, but not all. It is agreed on what it will do and not copy.

The actual call to the function looks like this: The copyfile(filePath, destPath, gState, COPYFILE_DATA | COPYFILE_ACL | COPYFILE_STAT | COPYFILE_XATTR);

error I am getting is not very helpful, just an IO 5 error.

Is there something I am missing that is causing it to not work for some files? Or copy the file so it doesn't certian? Are there better ways than copyfile for copying files and all their attributes / metadata?

Please do not suggest other programs that copy files other than what I am here for. Thank!

+3


source to share


1 answer


You will have to dig deeper to find your problem, luckily you can dig yourself up inside copyfile()

. Apple provides a complete source that you can link to your code and then trace back to find the problem.

Note. You may need to tweak the source a bit to compile it, but it's easy enough to do so. However, if you try to get stuck, ask another question with details of what you tried and what went wrong, someone will probably help you.



NTN

+1


source







All Articles