6 ms·
It's complicated. Posix "rename()" is now supposed to be atomic, but it isn't on NFS.[1] Windows has version problems. XP couldn't do an atomic rename. Vista
by Animats 10y ago
It's complicated.
Posix "rename()" is now supposed to be atomic, but it isn't on NFS.[1] Windows has version problems. XP couldn't do an atomic rename. Vista could for NTFS file systems, using the NTFS transactional rename function. That's now deprecated in favor of ReplaceFile, which came in with Windows 7.[2] That's supposed to be atomic even if a copy across file systems is required. Not sure about Windows file shares.
In MacOS X, "rename" was not atomic before 2011. It's now believed to be.[3]
Even with "rename", you have to find the directory in which the old file lives, and create the new file there (as something like a ".part" file) before renaming. This requires resolving symbolic links and such. So it's non-trivial to get this right. My point is that this should Just Work as the default.
[1] http://stackoverflow.com/questions/41362016/rename-atomicity-and-nfs http://stackoverflow.com/questions/41362016/rename-atomicity...
[2] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365512(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...
[3] http://www.weirdnet.nl/apple/rename.html http://www.weirdnet.nl/apple/rename.html