4 ms·
I use something akin to djb's Maildir delivery procedure when I want to be as close to sure as I can be that a file 'has been saved'. 1. Create a temp file on
by rikkus 11y ago
I use something akin to djb's Maildir delivery procedure when I want to be as close to sure as I can be that a file 'has been saved'.
1. Create a temp file on the same mount
2. Write data to file, checking return of each write(), then a final fsync(), and close()
3. link() to filename we actually want
I still haven't figured out how to be this safe on Windows, because AFAICT there's no atomic way to link() or 'move' a file - and they canned the transactional API for the filesystem. Any pointers to how to write files 'safely' on Windows would be much appreciated!
- pbsd 11y ago`ReplaceFile` is supposed to be atomic, at least according to the documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/hh802690(v=vs.85).aspx#applications_updating_a_single_file_with_document-like_data https://msdn.microsoft.com/en-us/library/windows/desktop/hh8...