diff --git a/file_monitor.h b/file_monitor.h new file mode 100644 index 0000000..8350d7c --- /dev/null +++ b/file_monitor.h @@ -0,0 +1,32 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; + +class FileMonitor { +public: + using FileCallback = std::function; + + FileMonitor(const std::string& root_path, FileCallback callback); + ~FileMonitor(); + + void start(); + void stop(); + +private: + void monitor_thread(); + void scan_directory(const fs::path& dir); + std::string read_file_content(const fs::path& path); + + std::string root_path_; + FileCallback callback_; + std::thread monitor_thread_; + std::atomic running_{false}; + std::unordered_map file_times_; +}; \ No newline at end of file