diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-10 15:44:16 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-14 15:09:11 +0200 |
commit | a9694ba06acc9ea225f83bbd31f93cbedec4ff0c (patch) | |
tree | a6ae896c965c6d99052167bba3ccbd22948730ca /src | |
parent | aee1a0c7df5b86c08c4ac3188b3635f8f9879129 (diff) | |
download | justbuild-a9694ba06acc9ea225f83bbd31f93cbedec4ff0c.tar.gz |
ArchiveOps: reduce verbosity in archive type enum
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 6 | ||||
-rw-r--r-- | src/other_tools/utils/archive_ops.cpp | 36 | ||||
-rw-r--r-- | src/other_tools/utils/archive_ops.hpp | 8 |
3 files changed, 21 insertions, 29 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 0c991ef1..7f0b30e0 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -31,12 +31,10 @@ namespace { std::filesystem::path const& dst_dir) noexcept -> std::optional<std::string> { if (repo_type == "archive") { - return ArchiveOps::ExtractArchive( - ArchiveType::kArchiveTypeTar, archive, dst_dir); + return ArchiveOps::ExtractArchive(ArchiveType::Tar, archive, dst_dir); } if (repo_type == "zip") { - return ArchiveOps::ExtractArchive( - ArchiveType::kArchiveTypeZip, archive, dst_dir); + return ArchiveOps::ExtractArchive(ArchiveType::Zip, archive, dst_dir); } return "unrecognized repository type"; } diff --git a/src/other_tools/utils/archive_ops.cpp b/src/other_tools/utils/archive_ops.cpp index c080c4e3..94c000c7 100644 --- a/src/other_tools/utils/archive_ops.cpp +++ b/src/other_tools/utils/archive_ops.cpp @@ -51,13 +51,13 @@ void archive_read_closer(archive* a_in) { auto enable_write_filter(archive* aw, ArchiveType type) -> bool { switch (type) { - case ArchiveType::kArchiveTypeTar: + case ArchiveType::Tar: return true; // no compression filter - case ArchiveType::kArchiveTypeTarGz: + case ArchiveType::TarGz: return (archive_write_add_filter_gzip(aw) == ARCHIVE_OK); - case ArchiveType::kArchiveTypeTarBz2: + case ArchiveType::TarBz2: return (archive_write_add_filter_bzip2(aw) == ARCHIVE_OK); - case ArchiveType::kArchiveTypeTarXz: + case ArchiveType::TarXz: return (archive_write_add_filter_xz(aw) == ARCHIVE_OK); default: return false; @@ -66,15 +66,15 @@ auto enable_write_filter(archive* aw, ArchiveType type) -> bool { auto enable_read_filter(archive* ar, ArchiveType type) -> bool { switch (type) { - case ArchiveType::kArchiveTypeTar: + case ArchiveType::Tar: // autodetect from supported compression filters return (archive_read_support_filter_xz(ar) == ARCHIVE_OK) and (archive_read_support_filter_gzip(ar) == ARCHIVE_OK) and (archive_read_support_filter_bzip2(ar) == ARCHIVE_OK); - case ArchiveType::kArchiveTypeTarGz: + case ArchiveType::TarGz: return (archive_read_support_filter_gzip(ar) == ARCHIVE_OK); - case ArchiveType::kArchiveTypeTarBz2: + case ArchiveType::TarBz2: return (archive_read_support_filter_bzip2(ar) == ARCHIVE_OK); - case ArchiveType::kArchiveTypeTarXz: + case ArchiveType::TarXz: return (archive_read_support_filter_xz(ar) == ARCHIVE_OK); default: return false; @@ -128,16 +128,16 @@ auto ArchiveOps::CopyData(archive* ar, archive* aw) auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type) -> std::optional<std::string> { switch (type) { - case ArchiveType::kArchiveTypeZip: { + case ArchiveType::Zip: { if (archive_write_set_format_zip(aw) != ARCHIVE_OK) { return std::string("ArchiveOps: ") + std::string(archive_error_string(aw)); } } break; - case ArchiveType::kArchiveTypeTar: - case ArchiveType::kArchiveTypeTarGz: - case ArchiveType::kArchiveTypeTarBz2: - case ArchiveType::kArchiveTypeTarXz: { + case ArchiveType::Tar: + case ArchiveType::TarGz: + case ArchiveType::TarBz2: + case ArchiveType::TarXz: { if ((archive_write_set_format_pax_restricted(aw) != ARCHIVE_OK) or not enable_write_filter(aw, type)) { return std::string("ArchiveOps: ") + @@ -151,16 +151,16 @@ auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type) auto ArchiveOps::EnableReadFormats(archive* ar, ArchiveType type) -> std::optional<std::string> { switch (type) { - case ArchiveType::kArchiveTypeZip: { + case ArchiveType::Zip: { if (archive_read_support_format_zip(ar) != ARCHIVE_OK) { return std::string("ArchiveOps: ") + std::string(archive_error_string(ar)); } } break; - case ArchiveType::kArchiveTypeTar: - case ArchiveType::kArchiveTypeTarGz: - case ArchiveType::kArchiveTypeTarBz2: - case ArchiveType::kArchiveTypeTarXz: { + case ArchiveType::Tar: + case ArchiveType::TarGz: + case ArchiveType::TarBz2: + case ArchiveType::TarXz: { if ((archive_read_support_format_tar(ar) != ARCHIVE_OK) or not enable_read_filter(ar, type)) { return std::string("ArchiveOps: ") + diff --git a/src/other_tools/utils/archive_ops.hpp b/src/other_tools/utils/archive_ops.hpp index 22cf7e4b..6ad5b7c4 100644 --- a/src/other_tools/utils/archive_ops.hpp +++ b/src/other_tools/utils/archive_ops.hpp @@ -25,13 +25,7 @@ using archive = struct archive; using archive_entry = struct archive_entry; } -enum class ArchiveType : size_t { - kArchiveTypeZip, - kArchiveTypeTar, - kArchiveTypeTarGz, - kArchiveTypeTarBz2, - kArchiveTypeTarXz -}; +enum class ArchiveType : size_t { Zip, Tar, TarGz, TarBz2, TarXz }; /// \brief Class handling archiving and unarchiving operations via libarchive class ArchiveOps { |