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: |
Patrick Williams | 42a44c2 | 2024-08-16 15:21:32 -0400 | [diff] [blame] | 17 | static std::unique_ptr<blobs::GenericBlobInterface> CreateCleanupHandler( |
| 18 | const std::string& blobId, const std::vector<std::string>& files, |
| 19 | std::unique_ptr<FileSystemInterface> helper); |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 20 | |
| 21 | FileCleanupHandler(const std::string& blobId, |
| 22 | const std::vector<std::string>& files, |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 23 | std::unique_ptr<FileSystemInterface> helper) : |
Patrick Williams | 42a44c2 | 2024-08-16 15:21:32 -0400 | [diff] [blame] | 24 | supported(blobId), files(files), helper(std::move(helper)) |
Patrick Venture | 9b37b09 | 2020-05-28 20:58:57 -0700 | [diff] [blame] | 25 | {} |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 26 | |
| 27 | ~FileCleanupHandler() = default; |
| 28 | FileCleanupHandler(const FileCleanupHandler&) = default; |
| 29 | FileCleanupHandler& operator=(const FileCleanupHandler&) = default; |
| 30 | FileCleanupHandler(FileCleanupHandler&&) = default; |
| 31 | FileCleanupHandler& operator=(FileCleanupHandler&&) = default; |
| 32 | |
| 33 | bool canHandleBlob(const std::string& path) override; |
| 34 | std::vector<std::string> getBlobIds() override; |
| 35 | bool commit(uint16_t session, const std::vector<uint8_t>& data) override; |
| 36 | |
| 37 | /* These methods return true without doing anything. */ |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 38 | bool open(uint16_t, uint16_t, const std::string&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 39 | { |
| 40 | return true; |
| 41 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 42 | bool close(uint16_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 43 | { |
| 44 | return true; |
| 45 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 46 | bool expire(uint16_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 47 | { |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | /* These methods are unsupported. */ |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 52 | bool deleteBlob(const std::string&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 53 | { |
| 54 | return false; |
| 55 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 56 | bool stat(const std::string&, blobs::BlobMeta*) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 57 | { |
| 58 | return false; |
| 59 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 60 | std::vector<uint8_t> read(uint16_t, uint32_t, uint32_t) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 61 | { |
| 62 | return {}; |
| 63 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 64 | bool write(uint16_t, uint32_t, const std::vector<uint8_t>&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 65 | { |
| 66 | return false; |
| 67 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 68 | bool writeMeta(uint16_t, uint32_t, const std::vector<uint8_t>&) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 69 | { |
| 70 | return false; |
| 71 | } |
Willy Tu | b487eb4 | 2021-09-16 21:44:43 -0700 | [diff] [blame] | 72 | bool stat(uint16_t, blobs::BlobMeta*) override |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 73 | { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | private: |
| 78 | std::string supported; |
| 79 | std::vector<std::string> files; |
Patrick Venture | 2950c25 | 2020-07-16 15:11:03 -0700 | [diff] [blame] | 80 | std::unique_ptr<FileSystemInterface> helper; |
Patrick Venture | 9efef5d | 2019-06-19 08:45:44 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace ipmi_flash |