[Qt-interest] 答复: QFileSystemWatcher monitor a shared directory
pengliang(彭亮)
pengliang at founder.com
Fri Dec 24 10:05:09 CET 2010
Hi
Thank you. WIN API can provide the information, but it can not monitor the sub directories which is a shared directory via samba!!!
So, I think it is an OS/File system problem.
Thanks
彭亮 Ken
-----邮件原件-----
发件人: qt-interest-bounces+pengliang=founder.com at qt.nokia.com [mailto:qt-interest-bounces+pengliang=founder.com at qt.nokia.com] 代表 Oliver.Knoll at comit.ch
发送时间: 2010年12月23日 19:06
收件人: qt-interest at trolltech.com
主题: Re: [Qt-interest] QFileSystemWatcher monitor a shared directory
On 2010-12-23 Pengliang(彭亮) pengliang(彭亮) wrote:
> I have written a program to monitor a shared directory(samba on
> Linux) use QFileSystemWatcher. (The program runs on Windows, monitor a Linux directory).
> 1. When a new file was created, it can not emit directoryChanged
> signal. If it monitored a windows directory, it can work.
QFileSystemWatcher depends on the supported features by the file system - especially on network drives this might or might not work.
> 2. The signal of directoryChanged(const QString &path) : why the
> parameter of path is the directory path monitored, I think should be
> the file path which was created or modified.
No, it is by design (and hence correct) that the reported path is the one of the directory which is being monitored and which has changed. Unfortunatelly you have to scan the content yourself again, as to decide whether a file therein has been added, removed or changed (e.g. by comparing to file last changed timestamps you have stored previously).
Not sure why the Qt API does not provide this info, but again this depends on the capabilities of the underlying OS/file system, and Qt being a cross-platform toolkit can - most often - only provide a "common denominator" of features supported on all platforms.
You might want to check with the win32 API directly, I think this question has popped up before a couple of years ago and I think the win32 API /does/ provide you with the desired information (which file exactly has changed in what way, given a directory).
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101224/0083eee9/attachment.html
More information about the Qt-interest-old
mailing list