-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsoftware_utils.hpp
42 lines (32 loc) · 1020 Bytes
/
software_utils.hpp
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
#pragma once
#include <boost/asio/io_context.hpp>
#include <filesystem>
namespace phosphor::software::utils
{
namespace fs = std::filesystem;
struct RemovablePath
{
fs::path path;
explicit RemovablePath(const fs::path& path) : path(path) {}
~RemovablePath()
{
if (!path.empty())
{
std::error_code ec;
fs::remove_all(path, ec);
}
}
RemovablePath(const RemovablePath& other) = delete;
RemovablePath& operator=(const RemovablePath& other) = delete;
RemovablePath(RemovablePath&&) = delete;
RemovablePath& operator=(RemovablePath&&) = delete;
};
/** @brief Untar the image
* @param[in] imageFd - The file descriptor of the image to untar.
* @param[in] extractDirPath - The destination directory for the untarred
* image.
* @param[out] bool - The result of the untar operation.
*/
bool unTar(int imageFd, const std::string& extractDirPath);
} // namespace phosphor::software::utils
boost::asio::io_context& getIOContext();