Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "fs.hpp" |
| 4 | |
| 5 | #include <blobs-ipmid/blobs.hpp> |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame^] | 6 | |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 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 | |
| 21 | FileCleanupHandler(const std::string& blobId, |
| 22 | const std::vector<std::string>& files, |
| 23 | const FileSystemInterface* helper = &fileSystemHelper) : |
| 24 | supported(blobId), |
| 25 | files(files), helper(helper) |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame^] | 26 | {} |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 27 | |
| 28 | ~FileCleanupHandler() = default; |
| 29 | FileCleanupHandler(const FileCleanupHandler&) = default; |
| 30 | FileCleanupHandler& operator=(const FileCleanupHandler&) = default; |
| 31 | FileCleanupHandler(FileCleanupHandler&&) = default; |
| 32 | FileCleanupHandler& operator=(FileCleanupHandler&&) = default; |
| 33 | |
| 34 | bool canHandleBlob(const std::string& path) override; |
| 35 | std::vector<std::string> getBlobIds() override; |
| 36 | bool commit(uint16_t session, const std::vector<uint8_t>& data) override; |
| 37 | |
| 38 | /* These methods return true without doing anything. */ |
| 39 | bool open(uint16_t session, uint16_t flags, |
| 40 | const std::string& path) override |
| 41 | { |
| 42 | return true; |
| 43 | } |
| 44 | bool close(uint16_t session) override |
| 45 | { |
| 46 | return true; |
| 47 | } |
| 48 | bool expire(uint16_t session) override |
| 49 | { |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | /* These methods are unsupported. */ |
| 54 | bool deleteBlob(const std::string& path) override |
| 55 | { |
| 56 | return false; |
| 57 | } |
| 58 | bool stat(const std::string& path, blobs::BlobMeta* meta) override |
| 59 | { |
| 60 | return false; |
| 61 | } |
| 62 | std::vector<uint8_t> read(uint16_t session, uint32_t offset, |
| 63 | uint32_t requestedSize) override |
| 64 | { |
| 65 | return {}; |
| 66 | } |
| 67 | bool write(uint16_t session, uint32_t offset, |
| 68 | const std::vector<uint8_t>& data) override |
| 69 | { |
| 70 | return false; |
| 71 | } |
| 72 | bool writeMeta(uint16_t session, uint32_t offset, |
| 73 | const std::vector<uint8_t>& data) override |
| 74 | { |
| 75 | return false; |
| 76 | } |
| 77 | bool stat(uint16_t session, blobs::BlobMeta* meta) override |
| 78 | { |
| 79 | return false; |
| 80 | } |
| 81 | |
| 82 | private: |
| 83 | std::string supported; |
| 84 | std::vector<std::string> files; |
| 85 | const FileSystemInterface* helper; |
| 86 | }; |
| 87 | |
| 88 | } // namespace ipmi_flash |