diff options
author | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-12 18:23:35 +0100 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-03-13 12:14:53 +0100 |
commit | 2bd069cdecb5371d906f8df9f5fb36f308d6296f (patch) | |
tree | 3db2cee634411639d520b2dee796b8a97b7342f6 /src/buildtool/storage/config.hpp | |
parent | f487f592fdc85fbdb95856abb7f4281dd4353da9 (diff) | |
download | justbuild-2bd069cdecb5371d906f8df9f5fb36f308d6296f.tar.gz |
Move storage-aware tmpdir creation to config
... as the fs_utils have a lot more dependencies making them usable
in less places. Moreover, this function also serves to shape the
layout of the local build root and hence is more appropriately
placed in the config anyway.
Diffstat (limited to 'src/buildtool/storage/config.hpp')
-rw-r--r-- | src/buildtool/storage/config.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/buildtool/storage/config.hpp b/src/buildtool/storage/config.hpp index 92358d12..858f74ff 100644 --- a/src/buildtool/storage/config.hpp +++ b/src/buildtool/storage/config.hpp @@ -38,6 +38,7 @@ #include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/gsl.hpp" +#include "src/utils/cpp/tmp_dir.hpp" /// \brief Global storage configuration. class StorageConfig { @@ -184,6 +185,15 @@ class StorageConfig { return EphemeralRoot() / "exec_root"; } + /// \brief Create a tmp directory with controlled lifetime for specific + /// operations (archive, zip, file, distdir checkouts; fetch; update). + [[nodiscard]] static auto CreateTypedTmpDir( + std::string const& type) noexcept -> TmpDirPtr { + // try to create parent dir + auto parent_path = EphemeralRoot() / "tmp-workspaces" / type; + return TmpDir::Create(parent_path); + } + private: [[nodiscard]] static auto Data() noexcept -> ConfigData& { static ConfigData instance{}; |