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