Last active
March 7, 2023 20:59
-
-
Save jsonzilla/5a0ef78526c8b898bfde507908c1810e to your computer and use it in GitHub Desktop.
Check the lask modified, if changed return true;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
std::chrono::time_point<std::chrono::system_clock> lastChangedFileTime; | |
bool SomeClass::NeedReload | |
{ | |
struct stat result; | |
if (stat(filePath.c_str(), &result) == 0) { | |
auto mod_time = result.st_mtime; | |
auto newTime = std::chrono::system_clock::from_time_t(mod_time); | |
if (newTime != lastChangedFileTime) { | |
lastChangedFileTime = newTime; | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment