| 1 | #pragma once | 
|---|---|
| 2 | |
| 3 | #include <Poco/File.h> | 
| 4 | #include <Poco/Timestamp.h> | 
| 5 | |
| 6 | #include <string> | 
| 7 | |
| 8 | |
| 9 | class FileUpdatesTracker | 
| 10 | { | 
| 11 | private: | 
| 12 | std::string path; | 
| 13 | Poco::Timestamp known_time; | 
| 14 | |
| 15 | public: | 
| 16 | FileUpdatesTracker(const std::string & path_) | 
| 17 | : path(path_) | 
| 18 | , known_time(0) | 
| 19 | {} | 
| 20 | |
| 21 | bool isModified() const | 
| 22 | { | 
| 23 | return getLastModificationTime() > known_time; | 
| 24 | } | 
| 25 | |
| 26 | void fixCurrentVersion() | 
| 27 | { | 
| 28 | known_time = getLastModificationTime(); | 
| 29 | } | 
| 30 | |
| 31 | private: | 
| 32 | Poco::Timestamp getLastModificationTime() const | 
| 33 | { | 
| 34 | return Poco::File(path).getLastModified(); | 
| 35 | } | 
| 36 | }; | 
| 37 | 
