#pragma once #include #include #include class HotReload { public: // Accept either a single script file or a directory to watch. If a directory is // provided, any change to any file in the directory will trigger a reload. HotReload(const std::string& pathToWatch); bool CheckForChanges(); void UpdateLastWriteTime(); private: std::string path; std::time_t lastWriteTime; std::time_t GetFileWriteTime(const std::string& filename); // Return the most recent write time found in the watched path. If `path` is a // directory, this scans all files (non-recursive) and returns the newest // modification time. If it's a file, it returns that file's write time. std::time_t GetLatestWriteTimeInPath(); };