DFileSystemWatcher Class
The DFileSystemWatcher class provides an interface for monitoring files and directories for modifications. More...
Header: | #include <DFileSystemWatcher> |
Since: | Qt 4.2 |
Note: All functions in this class are reentrant.
Detailed Description
The DFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
DFileSystemWatcher monitors the file system for changes to files and directories by watching a list of specified paths.
Call addPath() to watch a particular file or directory. Multiple paths can be added using the addPaths() function. Existing paths can be removed by using the removePath() and removePaths() functions.
DFileSystemWatcher examines each path added to it. Files that have been added to the DFileSystemWatcher can be accessed using the files() function, and directories using the directories() function.
The fileChanged() signal is emitted when a file has been modified, renamed or removed from disk. Similarly, the directoryChanged() signal is emitted when a directory or its contents is modified or removed. Note that DFileSystemWatcher stops monitoring files once they have been renamed or removed from disk, and directories once they have been removed from disk.
Note: On systems running a Linux kernel without inotify support, file systems that contain watched paths cannot be unmounted.
Note: Windows CE does not support directory monitoring by default as this depends on the file system driver installed.
Note: The act of monitoring files and directories for modifications consumes system resources. This implies there is a limit to the number of files and directories your process can monitor simultaneously. On all BSD variants, for example, an open file descriptor is required for each monitored file. Some system limits the number of open file descriptors to 256 by default. This means that addPath() and addPaths() will fail if your process tries to add more than 256 files or directories to the file system monitor. Also note that your process may have other file descriptors open in addition to the ones for files being monitored, and these other open descriptors also count in the total. OS X uses a different backend and does not suffer from this issue.
See also QFile and QDir.