blob: 5073d4688dc27b3884e218385d04d6dc6adc8d87 [file] [log] [blame]
#pragma once
#include "fs.hpp"
#include <blobs-ipmid/blobs.hpp>
#include <memory>
#include <string>
#include <vector>
namespace ipmi_flash
{
class FileCleanupHandler : public blobs::GenericBlobInterface
{
public:
static std::unique_ptr<blobs::GenericBlobInterface> CreateCleanupHandler(
const std::string& blobId, const std::vector<std::string>& files,
std::unique_ptr<FileSystemInterface> helper);
FileCleanupHandler(const std::string& blobId,
const std::vector<std::string>& files,
std::unique_ptr<FileSystemInterface> helper) :
supported(blobId), files(files), helper(std::move(helper))
{}
~FileCleanupHandler() = default;
FileCleanupHandler(const FileCleanupHandler&) = default;
FileCleanupHandler& operator=(const FileCleanupHandler&) = default;
FileCleanupHandler(FileCleanupHandler&&) = default;
FileCleanupHandler& operator=(FileCleanupHandler&&) = default;
bool canHandleBlob(const std::string& path) override;
std::vector<std::string> getBlobIds() override;
bool commit(uint16_t session, const std::vector<uint8_t>& data) override;
/* These methods return true without doing anything. */
bool open(uint16_t, uint16_t, const std::string&) override
{
return true;
}
bool close(uint16_t) override
{
return true;
}
bool expire(uint16_t) override
{
return true;
}
/* These methods are unsupported. */
bool deleteBlob(const std::string&) override
{
return false;
}
bool stat(const std::string&, blobs::BlobMeta*) override
{
return false;
}
std::vector<uint8_t> read(uint16_t, uint32_t, uint32_t) override
{
return {};
}
bool write(uint16_t, uint32_t, const std::vector<uint8_t>&) override
{
return false;
}
bool writeMeta(uint16_t, uint32_t, const std::vector<uint8_t>&) override
{
return false;
}
bool stat(uint16_t, blobs::BlobMeta*) override
{
return false;
}
private:
std::string supported;
std::vector<std::string> files;
std::unique_ptr<FileSystemInterface> helper;
};
} // namespace ipmi_flash