PDA

View Full Version : QFileSystemWatcher on a network mount



TMan
17th February 2010, 14:44
Hey all,

I have a network mounted home directory (on linux). I want to use QFileSystemWatcher on files in this network mount.

By default, QFileSystemWatcher uses inotify on linux (if supported by the kernel). However, inotify doesn't seem to work for files on a network mount.

Do any of you know of a workaround to get file system notifications for network mounts?

Thanks!

axeljaeger
17th February 2010, 15:20
The usual workaround for this is to use a timer and periodically check the last modified timestamp of a file.

TMan
17th February 2010, 15:40
Yes, I get that. However, the Qt documentation for QFileSystemWatcher says:

"Note: On systems running a Linux kernel without inotify support, file systems that contain watched paths cannot be unmounted."

From which I deduce that Qt itself will fall back to polling if inotify isn't available. Now it would be nice if I could force QFileSystemWatcher to use polling, but that doesn't appear to be in the documentation :(

TMan
17th February 2010, 15:51
I've been checking the sources and I think it may be possible to subclass qfilesystemwatcher and force it to use its polling watcher engine. Going to try that tomorrow, will post the results here of course :)

TMan
18th February 2010, 09:50
Okay, subclassing QFileSystemWatcher is not going to work because the implementation is private (pimpl). Any suggestions other than creating my own polling class would be more than welcome, I'm a bit out of options now :(

TMan
19th February 2010, 07:41
For anyone else having this problem, a "solution" can be found here: http://lists.trolltech.com/qt-interest/2008-02/thread00553-0.html