[Qt-interest] QFileSystemWatcher missing file changes?
Bob Hood
bhood2 at comcast.net
Tue Mar 16 23:14:30 CET 2010
I've been contemplating a new tool that I need, and I decided to explore
some of the options I need in Qt. One of the pieces requires monitoring
and response to changes in a point in a file system. This would include
file changes (modifications), additions, removals, and directory
additions and removals.
Instead of using operating-system specific functionality for such
notifications, it looked as though QFileSystemWatcher would be of
interest for this purpose. I wrote a small console application under
Windows using Qt 4.6.2 that watches a file or folder, and just reports
when the event occurs.
Unfortunately, QFileSystemWatcher doesn't behave the way I expect it
to. When watching a folder, it generates events for file additions and
removals, but does not report that the folder had a change when a file
is modified -- i.e., it's time stamp changes. Watching the file itself
causes a change event to occur when the file is touched, but not when I
watch the folder containing it.
I'd rather not tie my code down with operating system-specific code
(like FindFirstChangeNotification() under Windows), but it seems as
though it may be a far more efficient approach in my case than trying to
be platform-agnostic. I can have potentially tens of thousands of files
(or thousands of folders) to be monitored, and having to list them all
to the QFileSystemWatcher to monitor is unreasonable overhead (and as
I've read in the docs, not even possible on all platforms). Is this
lack of directory change notification on a file modification a bug, or
is QFileSystemWatcher just designed that way?
More information about the Qt-interest-old
mailing list