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, |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 19 | const std::vector<std::string>& files, |
| 20 | std::unique_ptr<FileSystemInterface> helper); |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 21 | |
| 22 | FileCleanupHandler(const std::string& blobId, |
| 23 | const std::vector<std::string>& files, |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 24 | std::unique_ptr<FileSystemInterface> helper) : |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 25 | supported(blobId), |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 26 | files(files), helper(std::move(helper)) |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 27 | {} |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 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. */ |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 40 | bool open(uint16_t, uint16_t, const std::string&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 41 | { |
| 42 | return true; |
| 43 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 44 | bool close(uint16_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 45 | { |
| 46 | return true; |
| 47 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 48 | bool expire(uint16_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 49 | { |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | /* These methods are unsupported. */ |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 54 | bool deleteBlob(const std::string&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 55 | { |
| 56 | return false; |
| 57 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 58 | bool stat(const std::string&, blobs::BlobMeta*) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 59 | { |
| 60 | return false; |
| 61 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 62 | std::vector<uint8_t> read(uint16_t, uint32_t, uint32_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 63 | { |
| 64 | return {}; |
| 65 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 66 | bool write(uint16_t, uint32_t, const std::vector<uint8_t>&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 67 | { |
| 68 | return false; |
| 69 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 70 | bool writeMeta(uint16_t, uint32_t, const std::vector<uint8_t>&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 71 | { |
| 72 | return false; |
| 73 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 74 | bool stat(uint16_t, blobs::BlobMeta*) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 75 | { |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | private: |
| 80 | std::string supported; |
| 81 | std::vector<std::string> files; |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 82 | std::unique_ptr<FileSystemInterface> helper; |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | } // namespace ipmi_flash |