FileSystemWatcherAsync is an implementation of SC::FileSystemWatcher that uses SC::Async.
The main reason for this class to exist in a dedicated library is to break the dependency of SC::FileSystemWatcher from SC::AsyncEventLoop.
Example:
eventLoopRunner.init(eventLoop);
{
if (notification.getFullPath(fullPath))
{
switch (notification.operation)
{
console.
print(
"Modified {} {}\n", notification.relativePath, fullPath.path.view());
break;
console.
print(
"AddRemoveRename {} {}\n", notification.relativePath, fullPath.path.view());
break;
}
}
};
SC_TRY(fileSystemWatcher.
watch(folderWatcher,
"/path/to/dir"));
- Note
- This class has been designed to be implemented with SC::AsyncEventLoop but it's probably possible implementing another backend using a different event loop library that is capable of providing similar abstractions for file polling and event loop wake-up from a foreign thread.