[Development] QFileSystemWatcher and Recursive Monitoring

logic.cpp logic.cpp at gmail.com
Mon Jul 23 17:07:20 CEST 2012


> I don't like your single signal design. It's cross platform only in that it
> will compile/function on every platform. The application will behave
> differently in the slot connected to said signal on mac than on
> windows/linux. We should not expect every _user_ app to have separate
> codepaths for different platforms. A.k.a exactly what Qt isn't about.
>

What else do you suggest then, should we make 3 separate classes one for each
OS?

> Just because you attempted the perfect solution once and failed, doesn't
> mean it can't be done. At the end of the day we just need some #ifdef
> Q_MAC_OSX (or maybe this can/should be in QPA) with boring file property
> (filename,filesize,maybe-crc32?,etc) comparison stuff before determing the
> proper signal to emit.
>

By all means, please do try to generate this in-memory snapshot of a sizable
directory tree (say 20,000 folders 150,000 files) with all the necessary info
you listed (filename,filesize etc.) and tell me how it goes.
Last I tried it on my own hard drive full of stuff (40k folders 300k files) it
1) consumed too huge an amount of memory, and 2) took too long to complete.

***

What I'm trying to achieve here is to have some kind of common cross platform
interface for file-system monitoring (in contrast to, for example, making 3
separate classes QWinWatcher QNixWatcher QMacWatcher which will force users to
have platform specific code) that works as similarly as possible on all OSs and
gracefully degrades as necessary. Users will be made aware of this degradation
and will know to check for it and program their code to cover the different
eventualities (like with a capabilities() function or some such).

In fact - as was noted in a previous post - even on Mac OS itself there can be
different features available depending on which version (Snow Leopard(-) vs.
Lion(+)) and not just any trivial feature difference, it's a huge & important
one; getting actual file-level details on what exactly changed, eliminating the
need for an existing snapshot to compare against! Will Qt not take advantage of
these features where available? Maybe not, I don't know... but if yes, it would
only make sense to have some sort of capabilities() function or some-such which
can dynamically inform users about what features are available and what isn't.

Anyway, that's just one idea of mine. Dunno if it works into Qt's way of doing
things. Please let me know. The questions remain as follows;
- Should it all be in one class?
    If yes, how to go about differences in features/functionality.
    Should we emit many different kinds of signals, or just 1 general signal.
    Should we do this all in QFileSystemWatcher, or another new class.
- Or should fs-watching exist in totally separate platform-specific classes?
- Other?

-regedit


More information about the Development mailing list