Last active
March 7, 2023 20:59
Revisions
-
jsonzilla revised this gist
Mar 7, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ std::chrono::time_point<std::chrono::system_clock> lastChangedFileTime; bool SomeClass::NeedReload { struct stat result; if (stat(filePath.c_str(), &result) == 0) { -
jsonzilla created this gist
Mar 7, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #include <chrono> #include <sys/types.h> #include <sys/stat.h> std::chrono::time_point<std::chrono::system_clock> lastChangedFileTime; bool SomeClass::NeedReaload { 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; }