mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
LibCore: Added FileWatcher, a binding for the watch_file syscall
This wrapper abstracts the watch_file setup and file handling, and allows using the watch_file events as part of the event loop via the Core::Notifier class. Also renames the existing DirectoryWatcher class to BlockingFileWatcher, and adds support for the Modified mode in this class.
This commit is contained in:
parent
0304ab3e67
commit
2acbb811b1
Notes:
sideshowbarker
2024-07-18 22:25:59 +09:00
Author: https://github.com/Dexesttp
Commit: 2acbb811b1
Pull-request: https://github.com/SerenityOS/serenity/pull/5271
7 changed files with 216 additions and 119 deletions
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/DirectoryWatcher.h>
|
||||
#include <LibCore/FileWatcher.h>
|
||||
#include <LibCoreDump/Backtrace.h>
|
||||
#include <LibCoreDump/Reader.h>
|
||||
#include <serenity.h>
|
||||
|
@ -89,11 +89,11 @@ int main()
|
|||
return 1;
|
||||
}
|
||||
|
||||
Core::DirectoryWatcher watcher { "/tmp/coredump" };
|
||||
Core::BlockingFileWatcher watcher { "/tmp/coredump" };
|
||||
while (true) {
|
||||
auto event = watcher.wait_for_event();
|
||||
ASSERT(event.has_value());
|
||||
if (event.value().type != Core::DirectoryWatcher::Event::Type::ChildAdded)
|
||||
if (event.value().type != Core::FileWatcherEvent::Type::ChildAdded)
|
||||
continue;
|
||||
auto coredump_path = event.value().child_path;
|
||||
dbgln("New coredump file: {}", coredump_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue