How to force fsync when using cv::imwrite in c++

540 views Asked by At

I am writing images to disk using cv::imwrite, but I need to make sure that the file is sync to disk after that function returns. Is there a way to guarantee that?

In order to use the system call fsync, I need a file descriptor, which I have no access when using cv::imwrite. Is there any work-around this?

1

There are 1 answers

0
alex On

You can use following system call that syncs the whole system:

system("sync");

Don't forget to include stdlib.h