1 /* 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> 20 21 #include <filesystem> 22 #include <memory> 23 #include <string> 24 #include <vector> 25 26 namespace ipmi_flash 27 { 28 29 std::unique_ptr<blobs::GenericBlobInterface> 30 FileCleanupHandler::CreateCleanupHandler( 31 const std::string& blobId, const std::vector<std::string>& files) 32 { 33 return std::make_unique<FileCleanupHandler>(blobId, files); 34 } 35 36 bool FileCleanupHandler::canHandleBlob(const std::string& path) 37 { 38 return (path == supported); 39 } 40 41 std::vector<std::string> FileCleanupHandler::getBlobIds() 42 { 43 return {supported}; 44 } 45 46 bool FileCleanupHandler::commit(uint16_t session, 47 const std::vector<uint8_t>& data) 48 { 49 namespace fs = std::filesystem; 50 51 for (const auto& file : files) 52 { 53 helper->remove(file); 54 } 55 56 return true; 57 } 58 59 } // namespace ipmi_flash 60