[fpc-pascal] FreePascal Windows - Force files to write to disk
james at productionautomation.net
Tue Mar 21 19:58:48 CET 2017
I have not tried FlushFileBuffers() yet, so I just tried it now, I am getting the same results. I have also tried disabling write caching in disk management and STILL have the same results. I am now thinking this is some caching being done on the SSD that is ignoring FlushFileBuffers() Probably a 'feature' designed to help extend the life of the SSD, but making it useless to store data that needs to survive a power failure.
I have tried running my freepascal program on a normal mechanical hard disk and flushfilebuffers() seems to be working as expected, Data is getting actually written to the disk and my 'power failure' is not affecting the data at all, but on the SSD, it's still just a correct length file of 00s
Does anyone know of a way to force critical data to be written to a SSD so it's not lost during a power failure?
From: fpc-pascal [mailto:fpc-pascal-bounces at lists.freepascal.org] On Behalf Of Henry Vermaak
Sent: Tuesday, March 21, 2017 11:08 AM
To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
Subject: Re: [fpc-pascal] FreePascal Windows - Force files to write to disk
On Tue, Mar 21, 2017 at 10:39:23AM -0400, James Richters wrote:
> I am still having this issue. I've managed to narrow down what is happening
> some. The problem is my data is not actually being written all the way to
> disk. I now have a repeatable proven method to reproduce the issue. Here
> is the sequence.
> In my freepascal console application, I create the file Assign file
> Rewrite file Writeln file Writeln file Writeln file ...
> Flush file
Have you tried using the FlushFileBuffers() Windows API? Something like
Add "windows" to the uses clause, obviously.
fpc-pascal maillist - fpc-pascal at lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
More information about the fpc-pascal