0

I'm writing a program which operates on a file (only reads the file), while another program is writing that file (I've no control over it to use events and I don't know the content of the file). I want a way to know when that program finished writing, to stop my program operating on the file. I used these two method but I don't know which one is reliable and more performance:

1- renaming file to another name, if success, rename it to original name.

2-flush file , if file size has not been changed for a while (e.g 5 sec) then stop operation.

which one is better? is there any better way (more reliable and more performance)?

I'm using windows 7 and qt5.2(or visual studio) for c++.

GingerJack
  • 3,044
  • 1
  • 17
  • 19
abdolahS
  • 663
  • 12
  • 35

1 Answers1

1

Qt provides a class called QFileSystemWatcher which allows you to monitor files and directories.

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121
GingerJack
  • 3,044
  • 1
  • 17
  • 19