DtkCore
DTK Core module
|
The DFileSystemWatcher class provides an interface for monitoring files and directories for modifications. 更多...
Public 成员函数 | |
DFileSystemWatcher (QObject *parent=Q_NULLPTR) | |
DFileSystemWatcher (const QStringList &paths, QObject *parent=Q_NULLPTR) | |
~DFileSystemWatcher () | |
bool | addPath (const QString &file) |
QStringList | addPaths (const QStringList &files) |
bool | removePath (const QString &file) |
QStringList | removePaths (const QStringList &files) |
QStringList | files () const |
QStringList | directories () const |
额外继承的成员函数 | |
![]() | |
DObject (DObject *parent=nullptr) | |
只有在不需要数据成员的派生类中才会使用 parent 父类指针 | |
DObject (DObjectPrivate &dd, DObject *parent=nullptr) | |
在派生类中比较常用的构造函数 dd 私有类对象 | |
![]() | |
QScopedPointer< DObjectPrivate > | d_d_ptr |
The DFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
\inmodule dtkcore
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.
\inmodule dtkcore
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.
\inmodule dtkcore
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.
Dtk::Core::DFileSystemWatcher::DFileSystemWatcher | ( | QObject * | parent = Q_NULLPTR | ) |
Constructs a new file system watcher object with the given parent.
Dtk::Core::DFileSystemWatcher::DFileSystemWatcher | ( | const QStringList & | paths, |
QObject * | parent = Q_NULLPTR |
||
) |
Constructs a new file system watcher object with the given parent which monitors the specified paths list.
Dtk::Core::DFileSystemWatcher::~DFileSystemWatcher | ( | ) |
Destroys the file system watcher.
bool Dtk::Core::DFileSystemWatcher::addPath | ( | const QString & | path | ) |
Adds path to the file system watcher if path exists. The path is not added if it does not exist, or if it is already being monitored by the file system watcher.
If path specifies a directory, the directoryChanged() signal will be emitted when path is modified or removed from disk; otherwise the fileChanged() signal is emitted when path is modified, renamed or removed.
If the watch was successful, true is returned.
Reasons for a watch failure are generally system-dependent, but may include the resource not existing, access failures, or the total watch count limit, if the platform has one.
QStringList Dtk::Core::DFileSystemWatcher::addPaths | ( | const QStringList & | paths | ) |
Adds each path in paths to the file system watcher. Paths are not added if they not exist, or if they are already being monitored by the file system watcher.
If a path specifies a directory, the directoryChanged() signal will be emitted when the path is modified or removed from disk; otherwise the fileChanged() signal is emitted when the path is modified, renamed, or removed.
The return value is a list of paths that could not be watched.
Reasons for a watch failure are generally system-dependent, but may include the resource not existing, access failures, or the total watch count limit, if the platform has one.
QStringList Dtk::Core::DFileSystemWatcher::directories | ( | ) | const |
Returns a list of paths to directories that are being watched.
QStringList Dtk::Core::DFileSystemWatcher::files | ( | ) | const |
Returns a list of paths to files that are being watched.
bool Dtk::Core::DFileSystemWatcher::removePath | ( | const QString & | path | ) |
Removes the specified path from the file system watcher.
If the watch is successfully removed, true is returned.
Reasons for watch removal failing are generally system-dependent, but may be due to the path having already been deleted, for example.
QStringList Dtk::Core::DFileSystemWatcher::removePaths | ( | const QStringList & | paths | ) |
Removes the specified paths from the file system watcher.
The return value is a list of paths which were not able to be unwatched successfully.
Reasons for watch removal failing are generally system-dependent, but may be due to the path having already been deleted, for example.