Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/NotifierBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,27 @@ auto NotifierBuilder::ignoreFile(inotifypp::filesystem::path file) -> NotifierBu
auto NotifierBuilder::onEvent(Event event, EventObserver eventObserver) -> NotifierBuilder&
{
mInotify->setEventMask(mInotify->getEventMask() | static_cast<std::uint32_t>(event));
mEventObserver[event] = eventObserver;
switch (event) {
case Event::move:
mEventObserver[Event::moved_from] = eventObserver;
mEventObserver[Event::moved_to] = eventObserver;
break;
case Event::close:
mEventObserver[Event::close_write] = eventObserver;
mEventObserver[Event::close_nowrite] = eventObserver;
break;
default:
mEventObserver[event] = eventObserver;
break;
}
return *this;
}

auto NotifierBuilder::onEvents(std::vector<Event> events, EventObserver eventObserver)
-> NotifierBuilder&
{
for (auto event : events) {
mInotify->setEventMask(mInotify->getEventMask() | static_cast<std::uint32_t>(event));
mEventObserver[event] = eventObserver;
onEvent(event, eventObserver);
}

return *this;
Expand Down