maintain treated message list to avoid leak
this piece of code could run on a spacecraft
Change-Id: I7f47ed35b5d03dc449bd8d9459682f2101c25518
diff --git a/include/fileutils.h b/include/fileutils.h
index f3bdb5c..434eac0 100644
--- a/include/fileutils.h
+++ b/include/fileutils.h
@@ -23,6 +23,7 @@
#include <cstdio>
#include <ios>
#include <filesystem>
+#include <map>
#ifndef _WIN32
#include <sys/stat.h> // mode_t
@@ -91,5 +92,21 @@
*/
int accessFile(const std::string& file, int mode);
+
+class IdList
+{
+public:
+ IdList() = default;
+ IdList(std::filesystem::path p): path(std::move(p)) {
+ load();
+ }
+ bool add(uint64_t id);
+private:
+ void load();
+ std::filesystem::path path;
+ std::map<uint64_t, std::chrono::system_clock::time_point> ids;
+ std::chrono::system_clock::time_point last_maintain;
+};
+
} // namespace fileutils
} // namespace dhtnet