19efef5d9SPatrick Venture #pragma once 29efef5d9SPatrick Venture 39efef5d9SPatrick Venture #include "fs.hpp" 49efef5d9SPatrick Venture 59efef5d9SPatrick Venture #include <blobs-ipmid/blobs.hpp> 69b37b095SPatrick Venture 79efef5d9SPatrick Venture #include <memory> 89efef5d9SPatrick Venture #include <string> 99efef5d9SPatrick Venture #include <vector> 109efef5d9SPatrick Venture 119efef5d9SPatrick Venture namespace ipmi_flash 129efef5d9SPatrick Venture { 139efef5d9SPatrick Venture 149efef5d9SPatrick Venture class FileCleanupHandler : public blobs::GenericBlobInterface 159efef5d9SPatrick Venture { 169efef5d9SPatrick Venture public: 17*42a44c28SPatrick Williams static std::unique_ptr<blobs::GenericBlobInterface> CreateCleanupHandler( 18*42a44c28SPatrick Williams const std::string& blobId, const std::vector<std::string>& files, 192950c258SPatrick Venture std::unique_ptr<FileSystemInterface> helper); 209efef5d9SPatrick Venture FileCleanupHandler(const std::string & blobId,const std::vector<std::string> & files,std::unique_ptr<FileSystemInterface> helper)219efef5d9SPatrick Venture FileCleanupHandler(const std::string& blobId, 229efef5d9SPatrick Venture const std::vector<std::string>& files, 232950c258SPatrick Venture std::unique_ptr<FileSystemInterface> helper) : 24*42a44c28SPatrick Williams supported(blobId), files(files), helper(std::move(helper)) 259b37b095SPatrick Venture {} 269efef5d9SPatrick Venture 279efef5d9SPatrick Venture ~FileCleanupHandler() = default; 289efef5d9SPatrick Venture FileCleanupHandler(const FileCleanupHandler&) = default; 299efef5d9SPatrick Venture FileCleanupHandler& operator=(const FileCleanupHandler&) = default; 309efef5d9SPatrick Venture FileCleanupHandler(FileCleanupHandler&&) = default; 319efef5d9SPatrick Venture FileCleanupHandler& operator=(FileCleanupHandler&&) = default; 329efef5d9SPatrick Venture 339efef5d9SPatrick Venture bool canHandleBlob(const std::string& path) override; 349efef5d9SPatrick Venture std::vector<std::string> getBlobIds() override; 359efef5d9SPatrick Venture bool commit(uint16_t session, const std::vector<uint8_t>& data) override; 369efef5d9SPatrick Venture 379efef5d9SPatrick Venture /* These methods return true without doing anything. */ open(uint16_t,uint16_t,const std::string &)38b487eb47SWilly Tu bool open(uint16_t, uint16_t, const std::string&) override 399efef5d9SPatrick Venture { 409efef5d9SPatrick Venture return true; 419efef5d9SPatrick Venture } close(uint16_t)42b487eb47SWilly Tu bool close(uint16_t) override 439efef5d9SPatrick Venture { 449efef5d9SPatrick Venture return true; 459efef5d9SPatrick Venture } expire(uint16_t)46b487eb47SWilly Tu bool expire(uint16_t) override 479efef5d9SPatrick Venture { 489efef5d9SPatrick Venture return true; 499efef5d9SPatrick Venture } 509efef5d9SPatrick Venture 519efef5d9SPatrick Venture /* These methods are unsupported. */ deleteBlob(const std::string &)52b487eb47SWilly Tu bool deleteBlob(const std::string&) override 539efef5d9SPatrick Venture { 549efef5d9SPatrick Venture return false; 559efef5d9SPatrick Venture } stat(const std::string &,blobs::BlobMeta *)56b487eb47SWilly Tu bool stat(const std::string&, blobs::BlobMeta*) override 579efef5d9SPatrick Venture { 589efef5d9SPatrick Venture return false; 599efef5d9SPatrick Venture } read(uint16_t,uint32_t,uint32_t)60b487eb47SWilly Tu std::vector<uint8_t> read(uint16_t, uint32_t, uint32_t) override 619efef5d9SPatrick Venture { 629efef5d9SPatrick Venture return {}; 639efef5d9SPatrick Venture } write(uint16_t,uint32_t,const std::vector<uint8_t> &)64b487eb47SWilly Tu bool write(uint16_t, uint32_t, const std::vector<uint8_t>&) override 659efef5d9SPatrick Venture { 669efef5d9SPatrick Venture return false; 679efef5d9SPatrick Venture } writeMeta(uint16_t,uint32_t,const std::vector<uint8_t> &)68b487eb47SWilly Tu bool writeMeta(uint16_t, uint32_t, const std::vector<uint8_t>&) override 699efef5d9SPatrick Venture { 709efef5d9SPatrick Venture return false; 719efef5d9SPatrick Venture } stat(uint16_t,blobs::BlobMeta *)72b487eb47SWilly Tu bool stat(uint16_t, blobs::BlobMeta*) override 739efef5d9SPatrick Venture { 749efef5d9SPatrick Venture return false; 759efef5d9SPatrick Venture } 769efef5d9SPatrick Venture 779efef5d9SPatrick Venture private: 789efef5d9SPatrick Venture std::string supported; 799efef5d9SPatrick Venture std::vector<std::string> files; 802950c258SPatrick Venture std::unique_ptr<FileSystemInterface> helper; 819efef5d9SPatrick Venture }; 829efef5d9SPatrick Venture 839efef5d9SPatrick Venture } // namespace ipmi_flash 84