1

i'm overwriting to file in 10mb chunks by WriteFile API
handle is opened using FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH |FILE_FLAG_RANDOM_ACCESS flags in CreateFile

my question is : what happens to the chunk if my app crashed/terminated/windows BSODed (i'm not asking about powerloss) does the 10mb chuck get overwritten fully , not written at all or partly written ?

if filesystem matters ,NTFS with features that are enabled by defualt in regular windows installation is my question

i'd like to know your experience or knowledge thanks in advance

morthy
  • 11
  • 3
  • Depends on the filesystem you're writing to. If you have journaling turned on etc. If you're on NTFS and you have journaling enabled then there is a chance that it would roll back. But it's just that... a chance. I would highly suggest you [read this for solutions](https://learn.microsoft.com/en-us/windows/win32/fileio/deprecation-of-txf) – Mgetz Aug 13 '21 at 13:40
  • @Mgetz it's for ntfs, i'will edit the question to mention that , i think you can write your comment as an answer and i'll accept it – morthy Aug 17 '21 at 21:55
  • So it would actually help more if we knew what you were trying to do. What NTFS does depends a lot on where your file is, if that folder has shadow copies turned on. Whether or not a write has completed. etc. This is why a common method of handling this is copy and swap. That way the original file is never corrupted. – Mgetz Aug 18 '21 at 13:05

0 Answers0