File deletion fails sometimes on Mac
Technical Q&A 1497
and this question (whose answer copied from the tech note) indicate that, when getting fBsyErr
from FSDeleteObject
, the proper workaround is to call FSUnlinkObject
on 10.5+.
What is the technical difference between the two APIs FSDeleteObject
and FSUnlinkObject
(other than noting that FSUnlinkObject
does not appear in the documentation)? Why should unlink
be the fallba开发者_C百科ck and not the primary API?
I'd guess that FSDeleteObject
came first because it continues a line of file-deletion functions that existed long before the Mac OS merged with Unix, whereas unlinking a file is a Unix concept.
The Apple document you linked explains the difference quite clearly. FSUnlinkObject has the same semantics as unlink() - deleting open files is allowed. FSDeleteObject does not allow deleting open files and returns that error code when you attempt to do so.
精彩评论