blob: 7f92d8761919858f4216be0beedf3d566fc5b739 [file] [log] [blame]
Patrick Venture9efef5d2019-06-19 08:45:44 -07001/*
2 * Copyright 2019 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "cleanup.hpp"
18
19#include <blobs-ipmid/blobs.hpp>
Patrick Venture9b37b092020-05-28 20:58:57 -070020
Patrick Venture9efef5d2019-06-19 08:45:44 -070021#include <memory>
22#include <string>
23#include <vector>
24
25namespace ipmi_flash
26{
27
28std::unique_ptr<blobs::GenericBlobInterface>
29 FileCleanupHandler::CreateCleanupHandler(
Patrick Venture2950c252020-07-16 15:11:03 -070030 const std::string& blobId, const std::vector<std::string>& files,
31 std::unique_ptr<FileSystemInterface> helper)
Patrick Venture9efef5d2019-06-19 08:45:44 -070032{
Patrick Venture2950c252020-07-16 15:11:03 -070033 return std::make_unique<FileCleanupHandler>(blobId, files,
34 std::move(helper));
Patrick Venture9efef5d2019-06-19 08:45:44 -070035}
36
37bool FileCleanupHandler::canHandleBlob(const std::string& path)
38{
39 return (path == supported);
40}
41
42std::vector<std::string> FileCleanupHandler::getBlobIds()
43{
44 return {supported};
45}
46
Willy Tub487eb42021-09-16 21:44:43 -070047bool FileCleanupHandler::commit(uint16_t, const std::vector<uint8_t>&)
Patrick Venture9efef5d2019-06-19 08:45:44 -070048{
Patrick Venture9efef5d2019-06-19 08:45:44 -070049 for (const auto& file : files)
50 {
51 helper->remove(file);
52 }
53
54 return true;
55}
56
57} // namespace ipmi_flash