corrado1972
30th July 2010, 23:24
Hello you all,
Here (http://www.qtcentre.org/threads/5627-how-to-get-the-added-file-name-when-using-QFileSystemWatcher) I've totally understood why qfilesystemwatcher does not provide a new file added informations when some folder monitored changes.
So, I want write a cross platform process/daemon/win32 service that do this task.
I thinked to write a class that contains a qfilesystemwatcher that monitor some folders and signals every changement. I want to save a list of all files of every folder, and compare it with a second "image" of directory files. The differences can lead me to detect which kind of modification happened to the folder watched.
Here is the main loop as I intend it:
1) start monitoring a folder, take the snapshot of the files presents into the folder.
2) when signal is raised, take second snapshot of files list, and do the comparison, determining which files are modified, deleted and added since the first snapshot.
3) moving the second snapshot to the first, and wait for next signal, then repeat to the point 2
Is this the correct QT way to do this in cross platform manner?
Or could you suggest me a better solution?
Which QT classes should I use to do the folder comparison, QDir?
I know that this solution will not perform much, but I don't mind of performances.
I need a simple solution to capture everz new files added to a folder with low changements in the timespawn.
Here (http://www.qtcentre.org/threads/5627-how-to-get-the-added-file-name-when-using-QFileSystemWatcher) I've totally understood why qfilesystemwatcher does not provide a new file added informations when some folder monitored changes.
So, I want write a cross platform process/daemon/win32 service that do this task.
I thinked to write a class that contains a qfilesystemwatcher that monitor some folders and signals every changement. I want to save a list of all files of every folder, and compare it with a second "image" of directory files. The differences can lead me to detect which kind of modification happened to the folder watched.
Here is the main loop as I intend it:
1) start monitoring a folder, take the snapshot of the files presents into the folder.
2) when signal is raised, take second snapshot of files list, and do the comparison, determining which files are modified, deleted and added since the first snapshot.
3) moving the second snapshot to the first, and wait for next signal, then repeat to the point 2
Is this the correct QT way to do this in cross platform manner?
Or could you suggest me a better solution?
Which QT classes should I use to do the folder comparison, QDir?
I know that this solution will not perform much, but I don't mind of performances.
I need a simple solution to capture everz new files added to a folder with low changements in the timespawn.