Comment by chemodax
10 years ago
In general this approach should work fine, but devil is in detail: 1. You have to flush change to temporary file before move because otherwise you may get empty file: OS may reorder move and write operations 2. After move you have to flush parent directory of destination file on Posix. Windows have special flag for MoveFileEx() to ensure that operation is done or you have to call FlushFileBuffers() for destination file.
Linked paper mention the many popular programs forgets about (1).
No comments yet
Contribute on Hacker News ↗