bios: delete persisted tables at startup

Leveraging the new registration scheme introduced in the previous
commit, delete persisted BIOS tables at PLDM daemon startup. This lets
us process new (via a firmware update, for eg) BIOS config JSONs.

Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: I2e7759261e80afb2f0a45d8598c36838ab530d54
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index c3a1c53..e9ed628 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -7,6 +7,7 @@
 #include <boost/crc.hpp>
 #include <chrono>
 #include <ctime>
+#include <filesystem>
 #include <memory>
 #include <numeric>
 #include <phosphor-logging/elog-errors.hpp>
@@ -16,9 +17,14 @@
 #include <variant>
 #include <vector>
 
+namespace fs = std::filesystem;
 using namespace pldm::responder::bios;
 using namespace bios_parser;
 
+constexpr auto stringTableFile = "stringTable";
+constexpr auto attrTableFile = "attributeTable";
+constexpr auto attrValTableFile = "attributeValueTable";
+
 namespace pldm
 {
 
@@ -74,6 +80,31 @@
 namespace bios
 {
 
+Handler::Handler()
+{
+    try
+    {
+        fs::remove(
+            fs::path(std::string(BIOS_TABLES_DIR) + "/" + stringTableFile));
+        fs::remove(
+            fs::path(std::string(BIOS_TABLES_DIR) + "/" + attrTableFile));
+        fs::remove(
+            fs::path(std::string(BIOS_TABLES_DIR) + "/" + attrValTableFile));
+    }
+    catch (const std::exception& e)
+    {
+    }
+
+    handlers.emplace(PLDM_GET_DATE_TIME,
+                     [this](const pldm_msg* request, size_t payloadLength) {
+                         return this->getDateTime(request, payloadLength);
+                     });
+    handlers.emplace(PLDM_GET_BIOS_TABLE,
+                     [this](const pldm_msg* request, size_t payloadLength) {
+                         return this->getBIOSTable(request, payloadLength);
+                     });
+}
+
 Response Handler::getDateTime(const pldm_msg* request, size_t /*payloadLength*/)
 {
     uint8_t seconds = 0;
@@ -805,11 +836,11 @@
     if (rc == PLDM_SUCCESS)
     {
         BIOSTable BIOSStringTable(
-            ((std::string(biosTablePath) + "/stringTable")).c_str());
+            (std::string(biosTablePath) + "/" + stringTableFile).c_str());
         BIOSTable BIOSAttributeTable(
-            ((std::string(biosTablePath) + "/attributeTable")).c_str());
+            (std::string(biosTablePath) + "/" + attrTableFile).c_str());
         BIOSTable BIOSAttributeValueTable(
-            ((std::string(biosTablePath) + "/attributeValueTable")).c_str());
+            (std::string(biosTablePath) + "/" + attrValTableFile).c_str());
         switch (tableType)
         {
             case PLDM_BIOS_STRING_TABLE: