#include #include #include #include #include #include "project.h" namespace fs = std::experimental::filesystem; #define MAX_WDS 16 class NotifyService { public: NotifyService() : inotify{IN_MODIFY | IN_MOVED_TO} {} void watch(std::shared_ptr project) { inotify.watchDirectoryRecursively(project->basepath); projects[project->basepath]= project; } void _poll() { auto event = inotify.nb_getNextEvent(); if (event) { if (event->recursive_root_path) { auto path = *event->recursive_root_path; if (projects.find(path) != projects.end()) { std::cout << "=== reloading shaders ===\n"; projects[path]->reload_shaders(); } } } } private: Inotify inotify; std::map> projects; };