blob: 7c528afa5e77bed5a03b2a93d3ee11031505c427 [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);
FileCleanupHandler(const std::string& blobId,
const std::vector<std::string>& files,
const FileSystemInterface* helper = &fileSystemHelper) :
supported(blobId),
files(files), helper(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 session, uint16_t flags,
const std::string& path) override
{
return true;
}
bool close(uint16_t session) override
{
return true;
}
bool expire(uint16_t session) override
{
return true;
}
/* These methods are unsupported. */
bool deleteBlob(const std::string& path) override
{
return false;
}
bool stat(const std::string& path, blobs::BlobMeta* meta) override
{
return false;
}
std::vector<uint8_t> read(uint16_t session, uint32_t offset,
uint32_t requestedSize) override
{
return {};
}
bool write(uint16_t session, uint32_t offset,
const std::vector<uint8_t>& data) override
{
return false;
}
bool writeMeta(uint16_t session, uint32_t offset,
const std::vector<uint8_t>& data) override
{
return false;
}
bool stat(uint16_t session, blobs::BlobMeta* meta) override
{
return false;
}
private:
std::string supported;
std::vector<std::string> files;
const FileSystemInterface* helper;
};
} // namespace ipmi_flash