Enable support to handle InternalFailure type dump, during elog restore
Resolves openbmc/openbmc#2078
Change-Id: Iea47b9b7c0cd6cae21642057b21c4e99d85be1e8
Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
diff --git a/dump_serialize.cpp b/dump_serialize.cpp
new file mode 100644
index 0000000..26990a0
--- /dev/null
+++ b/dump_serialize.cpp
@@ -0,0 +1,35 @@
+#include <cereal/types/set.hpp>
+#include <cereal/archives/binary.hpp>
+#include <fstream>
+
+#include "dump_serialize.hpp"
+
+namespace phosphor
+{
+namespace dump
+{
+namespace elog
+{
+
+void serialize(const ElogList& list, const fs::path& dir)
+{
+ std::ofstream os(dir.c_str(), std::ios::binary);
+ cereal::BinaryOutputArchive oarchive(os);
+ oarchive(list);
+}
+
+bool deserialize(const fs::path& path, ElogList& list)
+{
+ if (fs::exists(path))
+ {
+ std::ifstream is(path.c_str(), std::ios::in | std::ios::binary);
+ cereal::BinaryInputArchive iarchive(is);
+ iarchive(list);
+ return true;
+ }
+ return false;
+}
+
+} // namespace elog
+} // namespace dump
+} // namespace phosphor