1 #pragma once 2 3 #include "fs.hpp" 4 5 #include <blobs-ipmid/blobs.hpp> 6 7 #include <memory> 8 #include <string> 9 #include <vector> 10 11 namespace ipmi_flash 12 { 13 14 class FileCleanupHandler : public blobs::GenericBlobInterface 15 { 16 public: 17 static std::unique_ptr<blobs::GenericBlobInterface> 18 CreateCleanupHandler(const std::string& blobId, 19 const std::vector<std::string>& files, 20 std::unique_ptr<FileSystemInterface> helper); 21 22 FileCleanupHandler(const std::string& blobId, 23 const std::vector<std::string>& files, 24 std::unique_ptr<FileSystemInterface> helper) : 25 supported(blobId), 26 files(files), helper(std::move(helper)) 27 {} 28 29 ~FileCleanupHandler() = default; 30 FileCleanupHandler(const FileCleanupHandler&) = default; 31 FileCleanupHandler& operator=(const FileCleanupHandler&) = default; 32 FileCleanupHandler(FileCleanupHandler&&) = default; 33 FileCleanupHandler& operator=(FileCleanupHandler&&) = default; 34 35 bool canHandleBlob(const std::string& path) override; 36 std::vector<std::string> getBlobIds() override; 37 bool commit(uint16_t session, const std::vector<uint8_t>& data) override; 38 39 /* These methods return true without doing anything. */ 40 bool open(uint16_t session, uint16_t flags, 41 const std::string& path) override 42 { 43 return true; 44 } 45 bool close(uint16_t session) override 46 { 47 return true; 48 } 49 bool expire(uint16_t session) override 50 { 51 return true; 52 } 53 54 /* These methods are unsupported. */ 55 bool deleteBlob(const std::string& path) override 56 { 57 return false; 58 } 59 bool stat(const std::string& path, blobs::BlobMeta* meta) override 60 { 61 return false; 62 } 63 std::vector<uint8_t> read(uint16_t session, uint32_t offset, 64 uint32_t requestedSize) override 65 { 66 return {}; 67 } 68 bool write(uint16_t session, uint32_t offset, 69 const std::vector<uint8_t>& data) override 70 { 71 return false; 72 } 73 bool writeMeta(uint16_t session, uint32_t offset, 74 const std::vector<uint8_t>& data) override 75 { 76 return false; 77 } 78 bool stat(uint16_t session, blobs::BlobMeta* meta) override 79 { 80 return false; 81 } 82 83 private: 84 std::string supported; 85 std::vector<std::string> files; 86 std::unique_ptr<FileSystemInterface> helper; 87 }; 88 89 } // namespace ipmi_flash 90