PySide.QtCore.QFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
PySide.QtCore.QFileSystemWatcher monitors the file system for changes to files and directories by watching a list of specified paths.
调用 PySide.QtCore.QFileSystemWatcher.addPath() to watch a particular file or directory. Multiple paths can be added using the PySide.QtCore.QFileSystemWatcher.addPaths() function. Existing paths can be removed by using the PySide.QtCore.QFileSystemWatcher.removePath() and PySide.QtCore.QFileSystemWatcher.removePaths() 函数。
PySide.QtCore.QFileSystemWatcher examines each path added to it. Files that have been added to the PySide.QtCore.QFileSystemWatcher can be accessed using the PySide.QtCore.QFileSystemWatcher.files() function, and directories using the PySide.QtCore.QFileSystemWatcher.directories() 函数。
PySide.QtCore.QFileSystemWatcher.fileChanged() signal is emitted when a file has been modified, renamed or removed from disk. Similarly, the PySide.QtCore.QFileSystemWatcher.directoryChanged() signal is emitted when a directory or its contents is modified or removed. Note that PySide.QtCore.QFileSystemWatcher stops monitoring files once they have been renamed or removed from disk, and directories once they have been removed from disk.
注意
在不支持 inotify 的运行 Linux 内核的系统,无法取消挂载包含看守路径的文件系统。
注意
Windows CE does not support directory monitoring by default as this depends on the file system driver installed.
注意
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 Mac OS X 10.4 and 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 PySide.QtCore.QFileSystemWatcher.addPath() and PySide.QtCore.QFileSystemWatcher.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. Mac OS X 10.5 and up use a different backend and do not suffer from this issue.
| 参数: |
|
|---|
构造新的文件系统看守程序对象采用给定 parent .
构造新的文件系统看守程序对象采用给定 parent which monitors the specified paths 列表。
| 参数: | file – unicode |
|---|
添加 path 到文件系统看守程序若 path 存在。路径不被添加若路径不存在 (或路径已被文件系统看守程序所监视)。
若 path 指定目录, PySide.QtCore.QFileSystemWatcher.directoryChanged() signal will be emitted when path 被修改或从磁盘被移除;否则 PySide.QtCore.QFileSystemWatcher.fileChanged() signal is emitted when path 被修改、被重命名或被移除。
注意
There is a system dependent limit to the number of files and directories that can be monitored simultaneously. If this limit has been reached, path will not be added to the file system watcher, and a warning message will be printed to stderr .
| 参数: | 文件 – list of strings |
|---|
添加每个路径在 paths 到文件系统看守程序。路径不被添加若路径不存在 (或路径已被文件系统看守程序所监视)。
若路径指定目录, PySide.QtCore.QFileSystemWatcher.directoryChanged() signal will be emitted when the path is modified or removed from disk; otherwise the PySide.QtCore.QFileSystemWatcher.fileChanged() signal is emitted when the path is modified, renamed, or removed.
注意
There is a system dependent limit to the number of files and directories that can be monitored simultaneously. If this limit has been reached, the excess paths will not be added to the file system watcher, and a warning message will be printed to stderr for each path that could not be added.
| 返回类型: | 字符串列表 |
|---|
返回正被看守的目录路径列表。
| 参数: | path – unicode |
|---|
| 参数: | path – unicode |
|---|
| 返回类型: | 字符串列表 |
|---|
返回正被看守的文件路径列表。
| 参数: | file – unicode |
|---|
移除指定 path 从文件系统看守程序。
| 参数: | 文件 – list of strings |
|---|
移除指定 paths 从文件系统看守程序。