I am working on an application targeted to Mac OSX 10.6+ using Qt 4.7.4
I have a folder with as much as 1000 files + and some or many or even all of these files may be renamed or moved or deleted, so I want to report to my application if:
- File is renamed (report original and renamed filename)
- Folder renamed (report original and renamed folder name)
- File/folder is deleted (just report it as deleted)/moved (report the moved location)
PROBLEM: is the underlying system may (its MAY) only allow 256 descriptors to be monitored so at most 256 files! How can I over come this?
Note: used QFileSystemWatcher
interface (it has the above stated problem)
ALSO : How to handle in case of version lower than OSX 10.5
Do mention how do i get renamed filename/foldername
From the
QFileSystemWatcher
docs:So you should not need to worry about this at all in your case.
QFileSystemWatcher
doesn't provide the information you requested in your edit. It will emit signals when one of the paths it monitors changes, but in case of a rename, you won't get the new name. It's intended more for things like file manager programs that will just update/reload their current view on receipt of such events.If you need more information than that, you'll need to use OS specific APIs. You can look at the code Qt uses for different platforms in the Qt source. It's in
src/core/io/qfilsystemwatcher_*.[h|cpp]
.For Mac OS X 10.5 or greater, the underlying API used is the
FSEvents
API. You can read in the Technology Overview page:So that OS-level API doesn't provide what you want either directly.
For older versions of Mac OS X and FreeBSD, Qt uses the
kqueue
API, with theEVFILT_VNODE
event filter. That API doesn't provide the new name of a renamed file either.In short, either you'll need to code something yourself based on one of those APIs, find a library that does it (with guarantees that meet your needs), or you'll need to redesign your application. "Watching" a directory in a portable manner is at best very tricky, and generally race- and error-prone. If I were you, I wouldn't be too optimistic especially if your design requires that no "event" be missed.