Next article: Dashboard Rant
Tags: content-free humor
Going through some code, I came across a function called AtomicReplaceDirectory. The very first line of this function was a comment that said:
note, despite the name, this is *not* atomic.
Isn't it great when the name and the comments are at odds?
It's not quite as bad as it sounds; it turns out that an atomic directory replace operation is impossible to perform on Mac OS X (and pretty much any other OS/FS combination). This function performs a best effort at something that approximates an atomic directory replacement, so its name is reasonable in the end.
Comments:
Atomic file swaps are usually pretty easy. You get the files on the same disk, make a system call, the OS swaps the pointers around and you’re good. No matter what happens, you’ll either get the old file still there or you’ll get the new file. You’ll never get a corrupted or empty file. This technique doesn’t work for directories, though, so you just have to approximate it.
Comments RSS feed for this page
Add your thoughts, post a comment:
Spam and off-topic posts will be deleted without notice. Culprits may be publicly humiliated at my sole discretion.