Watcher prototype » History » Version 9
Greg Burri, 08/04/2009 10:24 AM
| 1 | 1 | Greg Burri | h1. Watcher prototype |
|---|---|---|---|
| 2 | |||
| 3 | 2 | Greg Burri | The cache file structure store all the hashes of the shared files. If a file is added or removed from a shared directory (or a subfolder) it should be added or removed from the cache. |
| 4 | |||
| 5 | 9 | Greg Burri | As far as I know there is no way to watch changes recursively of a folder tree with Qt. The Qt class _QFileSystemWatcher_ cannot watch recursively. |
| 6 | 2 | Greg Burri | |
| 7 | The only way to synchronize is to periodically scan all the shared data and compare to the cached one. It can be a bit CPU consumer so it should be done with a low priority thread and maybe with a pause between each file hashing. |
||
| 8 | 3 | Greg Burri | |
| 9 | 1 | Greg Burri | h2. Native solution |
| 10 | 9 | Greg Burri | |
| 11 | A better solution would be to use native platform API. |
||
| 12 | 1 | Greg Burri | |
| 13 | 8 | Greg Burri | h3. Linux : inotify |
| 14 | 1 | Greg Burri | |
| 15 | 8 | Greg Burri | On Linux it exists a function called "inotify":http://linux.die.net/man/7/inotify |
| 16 | |||
| 17 | 5 | Greg Burri | |
| 18 | 6 | Greg Burri | h3. Windows : FindFirstChangeNotification |
| 19 | 5 | Greg Burri | |
| 20 | On Windows a directory and its subtree can be watched, see : http://msdn.microsoft.com/en-us/library/aa365261%28VS.85%29.aspx |
||
| 21 | 7 | Greg Burri | There is a simple function called _ReadDirectoryChangesW_ : http://msdn.microsoft.com/en-us/library/aa365465%28VS.85%29.aspx |