Notifies about events (add, remove, rename, modified) on files and directories. More...
#include <FileSystemWatcher.h>
Classes | |
| struct | EventLoopRunner |
| Abstract class to use event loop notifications (see SC::FileSystemWatcherAsync). More... | |
| struct | FolderWatcher |
| Represents a single folder being watched. More... | |
| struct | Notification |
| Notification holding type and path. More... | |
Public Types | |
| enum class | Operation { Modified , AddRemoveRename } |
| Specifies the event classes. More... | |
| using | InternalOpaque = OpaqueObject<InternalDefinition> |
| using | ThreadRunner = OpaqueObject<ThreadRunnerDefinition> |
| Delivers notifications on a background thread. | |
Public Member Functions | |
| Result | init (ThreadRunner &runner) |
| Setup watcher to receive notifications from a background thread. | |
| Result | init (EventLoopRunner &runner) |
| Setup watcher to receive async notifications on an event loop. | |
| Result | close () |
| Stops all watchers and frees the ThreadRunner or EventLoopRunner passed in init. | |
| Result | watch (FolderWatcher &watcher, StringSpan path) |
| Starts watching a single directory, calling FolderWatcher::notifyCallback on file events. | |
| void | asyncNotify (FolderWatcher *watcher) |
Friends | |
| decltype(internal) friend decltype(FolderWatcher::internal) friend struct | EventLoopRunner |
Notifies about events (add, remove, rename, modified) on files and directories.
Caller can specify a callback for receiving notifications the SC::FileSystemWatcher::watch method.
Changes are grouped in two categories:
There are two modes in which FileSystemWatcher can be initialized, defining how notifications are delivered:
| Mode | Description |
|---|---|
| SC::FileSystemWatcher::ThreadRunner | Delivers notifications on a background thread. |
| SC::FileSystemWatcher::EventLoopRunner | Abstract class to use event loop notifications (see SC::FileSystemWatcherAsync). |
Example using SC::FileSystemWatcher::ThreadRunner:
Example using SC::FileSystemWatcherAsync (that implements SC::FileSystemWatcher::EventLoopRunner):
[OpaqueDeclarationSnippet]
| using SC::FileSystemWatcher::ThreadRunner = OpaqueObject<ThreadRunnerDefinition> |
Delivers notifications on a background thread.
|
strong |
Specifies the event classes.
Some events are grouped in a single one because it's non-trivial providing precise notifications that are consistent across platforms.
| Enumerator | |
|---|---|
| Modified | A file or directory has been modified in its contents and/or timestamp. |
| AddRemoveRename | A file or directory has been added, removed or renamed. |
| Result SC::FileSystemWatcher::close | ( | ) |
Stops all watchers and frees the ThreadRunner or EventLoopRunner passed in init.
| Result SC::FileSystemWatcher::init | ( | EventLoopRunner & | runner | ) |
Setup watcher to receive async notifications on an event loop.
| runner | Address of a EventLoopRunner object that must be valid until close() |
| Result SC::FileSystemWatcher::init | ( | ThreadRunner & | runner | ) |
| Result SC::FileSystemWatcher::watch | ( | FolderWatcher & | watcher, |
| StringSpan | path ) |
Starts watching a single directory, calling FolderWatcher::notifyCallback on file events.
| watcher | Reference to a (not already used) watcher, with a valid FolderWatcher::notifyCallback. Its address must not change until FolderWatcher::stopWatching or FileSystemWatcher::close |
| path | The directory being monitored |