Comment

Comment by waynecochran

The pain I had with atomic writing on Windows is that Windows rename does not behave like the POSIX standard:

https://msdn.microsoft.com/en-us/library/zw5t957f.aspx

      "The old name must be the path of an existing 
       file or directory. The new name must not be 
       the name of an existing file or directory."
I ended up having to use ReplaceFile and rename if ReplaceFile failed:

    ReplaceFile(tmpFileName, fileName, NULL, 
                REPLACEFILE_IGNORE_ACL_ERRORS, NULL, NULL) == 0 &&
    rename(tmpFileName, fileName);
https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...

Why Windows why?

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton