Re:Show HN: AtomicWrite: cross platform library for atomical...
by Goopplesoft on Tuesday March 13, 2018 @12:36AM
(#16573892)
I usually don't defend Windows, but, rename not overwriting (without an argument) seems safer as a low level API, no? Given it takes a 2 line helper to achieve the same thing in C++ [1], doesn't seem that bad.
[1] https://gitlab.com/jeffreyrogers27/AtomicWrite/blob/master/A...
Re:Show HN: AtomicWrite: cross platform library for atomical...
by fh973 on Tuesday March 13, 2018 @03:00AM
(#16574277)
Safety is usually not a design goal for low level APIs. You rather want it to be minimal, functions to be orthogonal, clean abstractions and only promise necessary semantics.
And this might be already the reason. Win32 is geared towards the broad range of developers whereas Unix comes more from systems thinking.
Re:Show HN: AtomicWrite: cross platform library for atomical...
by waynecochran on Tuesday March 13, 2018 @09:35AM
(#16575940)
I just want consistency. If the POSIX standard defines a function's behavior then you should either implement it by the standard or give it a different name.
Re:Show HN: AtomicWrite: cross platform library for atomical...
by abcd_f on Tuesday March 13, 2018 @03:59AM
(#16574449)
You may want to look at MoveFileEx
Re:Show HN: AtomicWrite: cross platform library for atomical...
by pjc50 on Tuesday March 13, 2018 @05:49AM
(#16574812)
This is the correct answer, with MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH
(I see that also provides MOVEFILE_DELAY_UNTIL_REBOOT as a workaround for executable images that are in use)
https://msdn.microsoft.com/en-us/library/zw5t957f.aspx
I ended up having to use ReplaceFile and rename if ReplaceFile failed: https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...Why Windows why?