[fpc-pascal] FreePascal Windows - Force files to write to disk
joshyfun at gmail.com
Wed Mar 22 20:59:20 CET 2017
El 22/03/2017 a las 19:17, James Richters escribió:
> Copy the file to the hard drive with a temporary name
> Flush all writes to above file
> Delete previous backup file
> Rename the original file to backup file name
> Rename the new recently copied file to the original name
Your problem seems to be that you are using an SSD without a big
capacitor (or partially damaged one) to preserve writes on power loss.
This fact combined with how TRIM works could create that effect.
You can try this steps:
1) Copy file content to .bak
2) Create new file with data (.datnew)
3) Close file (This forces SSD to write to an spare block)
4) Delete old file (This forces a TRIM sent to the SSD)
5) Rename file to original name.
In step 4, the delete should send a TRIM which could force a SSD-RAM to
NAND-SSD write to handle the TRIM. You must not delete 0 bytes (no TRIM)
nor files with a size less than 1024 (no TRIM in NTFS as most of them
are stored as resident data in MFT).
More information about the fpc-pascal