#include "dump_serialize.hpp" #include #include #include #include namespace phosphor { namespace dump { namespace elog { void serialize(const ElogList& list, const std::filesystem::path& dir) { std::ofstream os(dir.c_str(), std::ios::binary); cereal::BinaryOutputArchive oarchive(os); oarchive(list); } bool deserialize(const std::filesystem::path& path, ElogList& list) { try { if (std::filesystem::exists(path)) { std::ifstream is(path.c_str(), std::ios::in | std::ios::binary); cereal::BinaryInputArchive iarchive(is); iarchive(list); return true; } return false; } catch (const cereal::Exception& e) { lg2::error("Failed to deserialize, errormsg: {ERROR}", "ERROR", e); std::filesystem::remove(path); return false; } } } // namespace elog } // namespace dump } // namespace phosphor