1*cab87e9cSJagpal Singh Gill #pragma once 2*cab87e9cSJagpal Singh Gill 3*cab87e9cSJagpal Singh Gill #include <boost/asio/io_context.hpp> 4*cab87e9cSJagpal Singh Gill 5*cab87e9cSJagpal Singh Gill #include <filesystem> 6*cab87e9cSJagpal Singh Gill 7*cab87e9cSJagpal Singh Gill namespace phosphor::software::utils 8*cab87e9cSJagpal Singh Gill { 9*cab87e9cSJagpal Singh Gill 10*cab87e9cSJagpal Singh Gill namespace fs = std::filesystem; 11*cab87e9cSJagpal Singh Gill 12*cab87e9cSJagpal Singh Gill struct RemovablePath 13*cab87e9cSJagpal Singh Gill { 14*cab87e9cSJagpal Singh Gill fs::path path; 15*cab87e9cSJagpal Singh Gill RemovablePathphosphor::software::utils::RemovablePath16*cab87e9cSJagpal Singh Gill explicit RemovablePath(const fs::path& path) : path(path) {} ~RemovablePathphosphor::software::utils::RemovablePath17*cab87e9cSJagpal Singh Gill ~RemovablePath() 18*cab87e9cSJagpal Singh Gill { 19*cab87e9cSJagpal Singh Gill if (!path.empty()) 20*cab87e9cSJagpal Singh Gill { 21*cab87e9cSJagpal Singh Gill std::error_code ec; 22*cab87e9cSJagpal Singh Gill fs::remove_all(path, ec); 23*cab87e9cSJagpal Singh Gill } 24*cab87e9cSJagpal Singh Gill } 25*cab87e9cSJagpal Singh Gill 26*cab87e9cSJagpal Singh Gill RemovablePath(const RemovablePath& other) = delete; 27*cab87e9cSJagpal Singh Gill RemovablePath& operator=(const RemovablePath& other) = delete; 28*cab87e9cSJagpal Singh Gill RemovablePath(RemovablePath&&) = delete; 29*cab87e9cSJagpal Singh Gill RemovablePath& operator=(RemovablePath&&) = delete; 30*cab87e9cSJagpal Singh Gill }; 31*cab87e9cSJagpal Singh Gill 32*cab87e9cSJagpal Singh Gill /** @brief Untar the image 33*cab87e9cSJagpal Singh Gill * @param[in] imageFd - The file descriptor of the image to untar. 34*cab87e9cSJagpal Singh Gill * @param[in] extractDirPath - The destination directory for the untarred 35*cab87e9cSJagpal Singh Gill * image. 36*cab87e9cSJagpal Singh Gill * @param[out] bool - The result of the untar operation. 37*cab87e9cSJagpal Singh Gill */ 38*cab87e9cSJagpal Singh Gill bool unTar(int imageFd, const std::string& extractDirPath); 39*cab87e9cSJagpal Singh Gill 40*cab87e9cSJagpal Singh Gill } // namespace phosphor::software::utils 41*cab87e9cSJagpal Singh Gill 42*cab87e9cSJagpal Singh Gill boost::asio::io_context& getIOContext(); 43