[fpc-pascal] FreePascal Windows - Force files to write to disk

Henry Vermaak henry.vermaak at gmail.com
Wed Mar 22 15:27:38 CET 2017

On Wed, Mar 22, 2017 at 01:50:45PM +0100, Karoly Balogh (Charlie/SGR) wrote:
> The usual way to work this problem around on Linux systems at least, is to
> write a new file, then do an overwriting rename to the old file name.
> There rename is an "atomic" operation, which will be either committed to
> the disk or not, but if it was unsuccessful, you won't end up with
> half-written files. But IIRC Windows didn't support atomic renames. Maybe
> someone with more Windows knowledge will fix me. You definitely don't want
> to implement a copy though, and that's anything but atomic.

I remember discussions about atomic rename for go and python (you can
still find the bug reports online).  The consensus seems to be that
flags will be atomic if the file is on the same volume, and if that
volume supports changing the metadata in one transaction (which most do,

MSDN recommends ReplaceFile() instead of TxF:


But I _think_ this is just a convenience function that uses

So you can basically follow the same strategy as on POSIX, but with


More information about the fpc-pascal mailing list