[fpc-pascal] FreePascal Windows - Force files to write to disk
Jonas Maebe
jonas at freepascal.org
Tue Mar 21 19:23:49 CET 2017
On 21/03/17 15:39, James Richters wrote:
> If I then power off the test computer (not doing a correct windows shutdown,
> this simulates an unattended power failure) when it boots back up, my file
> has the correct date and time and the correct length, hovever the contents
> of the file is a string of $00 with no other characters, no carriage returns
> and no linefeeds, however the number of $00s is EXACTLY how many bytes the
> file should have been. It's like the file was allocated but data not
> actually written to disk yet... but I thought Close (file) was supposed to
> do that.
No, it does not do that. It flushes everything from the internal program
buffers to the operating system, but the operating system will perform
write-back caching. This is not specific to FPC programs, it does this
almost all writes to a regular hard drive or SSD (Windows does not do it
for USB sticks, afaik). Not doing so would slow down you system
significantly.
Jonas
More information about the fpc-pascal
mailing list