0

I use basic_managed_mapped_file and I want to backup the file while the program is running.

How can I make sure the data is written to disk for the backup?

nobody
  • 19,814
  • 17
  • 56
  • 77
youngxiao
  • 21
  • 2

1 Answers1

0

The answer is logically "yes".

The operating system will make sure that the data is written, I believe even if your process would crash next.

However, if you

  • must be sure that the data hit the disk before doing anything else
  • need to ensure that data hits the disk in any particular order (e.g. journaling/intent logging)
  • need to be sure that data is safely written in the face of e.g. power failure

then you will need to add a disk sync call on most OS-es. If you require this level of detail (and worse, in portable fashion), the topic quickly becomes hard, and I defer to

eat my data: how everybody gets file IO wrong from Stewart Smith

I've also mirrored the video/slides just in case (see here)

Community
  • 1
  • 1
sehe
  • 374,641
  • 47
  • 450
  • 633