| 1 |
/*! |
| 2 |
@~chinese |
| 3 |
@ingroup dfilesystem |
| 4 |
@file include/filesystem/dfilesystemwatcher.h |
| 5 |
|
| 6 |
@class DFileSystemWatcher |
| 7 |
@brief 监听文件系统变化的类 |
| 8 |
@details |
| 9 |
DFileSystemWatcher监视文件系统对文件的更改和目录,通过观察指定的path列表。<br> |
| 10 |
调用addPath()来监视特定的文件或目录。多个path可以使用addPaths()函数添加。现有path可以使用removePath()和removePaths()函数删除。<br> |
| 11 |
DFileSystemWatcher检查添加到其中的每个path。具有以下特性的文件添加到DFileSystemWatcher可以使用函数Files()和使用函数directories()创建的目录。<br> |
| 12 |
fileChanged()信号在文件被修改时发出,重命名或从磁盘中删除。类似地,directoryChanged()在目录或其内容被修改或移除。<br> |
| 13 |
请注意,DFileSystemWatcher只停止监视一次文件,它们被重命名或从磁盘和目录中删除一次,它们已从磁盘中移除。 |
| 14 |
@note 在运行不支持inotify的Linux内核的系统上,包含被监视路径的文件系统不能被卸载。<br> |
| 15 |
默认情况下,Windows CE不支持目录监控,这取决于安装的文件系统驱动程序。<br> |
| 16 |
监视文件和目录的行为修改操作会消耗系统资源。这意味着有一个限制进程可以使用的文件和目录的数量同时监控。 |
| 17 |
|
| 18 |
@fn DFileSystemWatcher::DFileSystemWatcher(QObject *parent) |
| 19 |
@brief 构造函数,构造一个新的文件系统监视器对象。 |
| 20 |
|
| 21 |
@fn DFileSystemWatcher::DFileSystemWatcher(const QStringList &paths, QObject *parent = Q_NULLPTR) |
| 22 |
@brief 构造函数,构造一个新的文件系统监视器对象,监控指定路径列表。 |
| 23 |
@param paths 要监听的路径列表 |
| 24 |
|
| 25 |
@fn bool DFileSystemWatcher::addPath(const QString &file) |
| 26 |
@brief 添加要监听的路径 |
| 27 |
@details 如果path存在,则将path添加到文件系统监视器。如果path不存在或已经存在,则不添加它由文件系统监视程序监视。<br> |
| 28 |
如果path指定了一个目录,则调用directoryChanged()信号将在path被修改或从磁盘中删除时发出。否则,当path被修改、重命名或删除。,就会触发fileChanged()信号<br> |
| 29 |
如果监视成功,则返回true。<br> |
| 30 |
监视故障的原因通常与系统有关,但是可能包括资源不存在、访问失败或总监视数量限制,如果平台有一个。 |
| 31 |
@note 可能有一个系统依赖的数量限制可以同时监控的文件和目录。<br> |
| 32 |
如果达到了这个限制,path将不会被监控,返回false。 |
| 33 |
@param[in] file 要监听的路径 |
| 34 |
@sa DFileSystemWatcher::addPaths() |
| 35 |
@sa DFileSystemWatcher::removePath() |
| 36 |
|
| 37 |
@fn QStringList DFileSystemWatcher::addPaths(const QStringList &files) |
| 38 |
@brief 添加要监听的路径列表 |
| 39 |
@details 将path中的每个path添加到文件系统监视程序。path如果不存在,或者已经存在,则不添加由文件系统监视程序监视。<br> |
| 40 |
如果path指定了一个目录,则调用directoryChanged()信号将在path被修改或从磁盘中删除时触发。否则,当path被修改、重命名或删除。,就会触发fileChanged()信号<br> |
| 41 |
返回值是一个无法被监视的路径列表。<br> |
| 42 |
监视故障的原因通常与系统有关,但是可能包括资源不存在、访问失败或总监视数量限制,如果平台有一个。<br> |
| 43 |
@note 可能有一个系统依赖的数量限制可以同时监控的文件和目录。<br> |
| 44 |
如果达到了这个限制,多余的path就不会达到,它们将被添加到返回的QStringList中。 |
| 45 |
@param[in] files 要监听的路径列表 |
| 46 |
@sa DFileSystemWatcher::addPath() |
| 47 |
@sa DFileSystemWatcher::removePaths() |
| 48 |
|
| 49 |
@fn bool DFileSystemWatcher::removePath(const QString &file) |
| 50 |
@brief 移除监听的路径 |
| 51 |
@details 从文件系统监视程序中删除指定的path。<br> |
| 52 |
如果监视成功删除,则返回true。<br> |
| 53 |
监视删除失败的原因通常与系统有关,但可能是因为path已经被删除了。 |
| 54 |
@sa DFileSystemWatcher::removePaths() |
| 55 |
@sa DFileSystemWatcher::addPath() |
| 56 |
|
| 57 |
@fn QStringList DFileSystemWatcher::removePaths(const QStringList &files) |
| 58 |
@brief 移除监听的路径列表 |
| 59 |
@details 从文件系统监视程序中删除指定的path。<br> |
| 60 |
返回值是一个无法被监视的路径列表。<br> |
| 61 |
监视删除失败的原因通常与系统有关,但可能是因为path已经被删除了。 |
| 62 |
@sa DFileSystemWatcher::removePath() |
| 63 |
@sa DFileSystemWatcher::addPaths() |
| 64 |
|
| 65 |
@fn QStringList DFileSystemWatcher::directories() const |
| 66 |
@brief 获取监听的目录列表 |
| 67 |
@sa DFileSystemWatcher::files() |
| 68 |
|
| 69 |
@fn QStringList DFileSystemWatcher::files() const |
| 70 |
@brief 获取监听的文件列表 |
| 71 |
@sa DFileSystemWatcher::directories() |
| 72 |
|
| 73 |
*/ |