diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/utils.cpp | 7 | ||||
-rw-r--r-- | src/other_tools/just_mr/utils.hpp | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/other_tools/just_mr/utils.cpp b/src/other_tools/just_mr/utils.cpp index 92563824..57ef6830 100644 --- a/src/other_tools/just_mr/utils.cpp +++ b/src/other_tools/just_mr/utils.cpp @@ -55,6 +55,13 @@ auto GetDistdirTreeIDFile(std::string const& content) noexcept return StorageConfig::BuildRoot() / "distfiles-tree-map" / content; } +auto GetResolvedTreeIDFile(std::string const& tree_hash, + PragmaSpecial const& pragma_special) noexcept + -> std::filesystem::path { + return StorageConfig::BuildRoot() / "special-tree-map" / + kPragmaSpecialInverseMap.at(pragma_special) / tree_hash; +} + auto WriteTreeIDFile(std::filesystem::path const& tree_id_file, std::string const& tree_id) noexcept -> bool { // needs to be done safely, so use the rename trick diff --git a/src/other_tools/just_mr/utils.hpp b/src/other_tools/just_mr/utils.hpp index 67878445..92d679e2 100644 --- a/src/other_tools/just_mr/utils.hpp +++ b/src/other_tools/just_mr/utils.hpp @@ -102,6 +102,12 @@ std::unordered_map<std::string, PragmaSpecial> const kPragmaSpecialMap = { {"resolve-partially", PragmaSpecial::ResolvePartially}, {"resolve-completely", PragmaSpecial::ResolveCompletely}}; +/// \brief Pragma "special" value inverse map, from enum to string +std::unordered_map<PragmaSpecial, std::string> const kPragmaSpecialInverseMap = + {{PragmaSpecial::Ignore, "ignore"}, + {PragmaSpecial::ResolvePartially, "resolve-partially"}, + {PragmaSpecial::ResolveCompletely, "resolve-completely"}}; + namespace JustMR { struct Paths { @@ -169,6 +175,11 @@ namespace Utils { [[nodiscard]] auto GetDistdirTreeIDFile(std::string const& content) noexcept -> std::filesystem::path; +/// \brief Get the path to the file storing a resolved tree hash. +[[nodiscard]] auto GetResolvedTreeIDFile( + std::string const& tree_hash, + PragmaSpecial const& pragma_special) noexcept -> std::filesystem::path; + /// \brief Write a tree id to file. The parent folder of the file must exist! [[nodiscard]] auto WriteTreeIDFile(std::filesystem::path const& tree_id_file, std::string const& tree_id) noexcept -> bool; |