2017-11-28 22:15:06 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Timestamp.h>
|
|
|
|
#include <string>
|
2021-04-30 20:16:35 +00:00
|
|
|
#include <filesystem>
|
2021-05-28 21:57:53 +00:00
|
|
|
#include <Common/filesystemHelpers.h>
|
2017-11-28 22:15:06 +00:00
|
|
|
|
2021-04-30 20:16:35 +00:00
|
|
|
namespace fs = std::filesystem;
|
2017-11-28 22:15:06 +00:00
|
|
|
|
|
|
|
class FileUpdatesTracker
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string path;
|
|
|
|
Poco::Timestamp known_time;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FileUpdatesTracker(const std::string & path_)
|
|
|
|
: path(path_)
|
|
|
|
, known_time(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool isModified() const
|
|
|
|
{
|
|
|
|
return getLastModificationTime() > known_time;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fixCurrentVersion()
|
|
|
|
{
|
|
|
|
known_time = getLastModificationTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Poco::Timestamp getLastModificationTime() const
|
|
|
|
{
|
2021-05-28 18:17:16 +00:00
|
|
|
return FS::getModificationTimestamp(path);
|
2017-11-28 22:15:06 +00:00
|
|
|
}
|
|
|
|
};
|