void FileEventSubscriber::configure() { // Clear all monitors from INotify. // There may be a better way to find the set intersection/difference. auto pub = getPublisher(); pub->removeSubscriptions(); auto parser = Config::getParser("file_paths"); auto& accesses = parser->getData().get_child("file_accesses"); Config::getInstance().files([this, &accesses]( const std::string& category, const std::vector<std::string>& files) { for (const auto& file : files) { VLOG(1) << "Added file event listener to: " << file; auto sc = createSubscriptionContext(); // Use the filesystem globbing pattern to determine recursiveness. sc->recursive = 0; sc->path = file; sc->mask = kFileDefaultMasks; if (accesses.count(category) > 0) { sc->mask |= kFileAccessMasks; } sc->category = category; subscribe(&FileEventSubscriber::Callback, sc); } }); }
void FileEventSubscriber::configure() { // Clear all paths from FSEvents. // There may be a better way to find the set intersection/difference. removeSubscriptions(); Config::get().files([this](const std::string& category, const std::vector<std::string>& files) { for (const auto& file : files) { VLOG(1) << "Added file event listener to: " << file; auto sc = createSubscriptionContext(); sc->path = file; sc->category = category; subscribe(&FileEventSubscriber::Callback, sc); } }); }