summaryrefslogtreecommitdiffstats
path: root/cleanup/cleanup.hpp
blob: 7c528afa5e77bed5a03b2a93d3ee11031505c427 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#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
OpenPOWER on IntegriCloud