[fpc-pascal] FreePascal Windows - Force files to write to disk
Karoly Balogh (Charlie/SGR)
charlie at scenergy.dfmk.hu
Wed Mar 22 14:12:34 CET 2017
On Wed, 22 Mar 2017, Karoly Balogh (Charlie/SGR) wrote:
> However, please note that transactional file handling on power loss is a
> quite delicate scenario, so you might not be able to solve all the related
> problems with this - what happens exactly when you get a power loss during
> a write, might be matter of pure luck.
> 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.
Actually, this blogpost which I've just found also details the algorithm
how you should do it, from a Windows perspective:
More information about the fpc-pascal