summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp3
-rw-r--r--src/other_tools/utils/archive_ops.cpp12
-rw-r--r--src/other_tools/utils/archive_ops.hpp9
-rw-r--r--test/other_tools/utils/archive_usage.test.cpp4
4 files changed, 22 insertions, 6 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index 7f0b30e0..5fb1bd88 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -31,7 +31,8 @@ namespace {
std::filesystem::path const& dst_dir) noexcept
-> std::optional<std::string> {
if (repo_type == "archive") {
- return ArchiveOps::ExtractArchive(ArchiveType::Tar, archive, dst_dir);
+ return ArchiveOps::ExtractArchive(
+ ArchiveType::TarAuto, archive, dst_dir);
}
if (repo_type == "zip") {
return ArchiveOps::ExtractArchive(ArchiveType::Zip, archive, dst_dir);
diff --git a/src/other_tools/utils/archive_ops.cpp b/src/other_tools/utils/archive_ops.cpp
index 94c000c7..7115680f 100644
--- a/src/other_tools/utils/archive_ops.cpp
+++ b/src/other_tools/utils/archive_ops.cpp
@@ -66,16 +66,16 @@ auto enable_write_filter(archive* aw, ArchiveType type) -> bool {
auto enable_read_filter(archive* ar, ArchiveType type) -> bool {
switch (type) {
- 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::Tar:
+ return true; // no compression filter
case ArchiveType::TarGz:
return (archive_read_support_filter_gzip(ar) == ARCHIVE_OK);
case ArchiveType::TarBz2:
return (archive_read_support_filter_bzip2(ar) == ARCHIVE_OK);
case ArchiveType::TarXz:
return (archive_read_support_filter_xz(ar) == ARCHIVE_OK);
+ case ArchiveType::TarAuto:
+ return (archive_read_support_filter_all(ar) == ARCHIVE_OK);
default:
return false;
}
@@ -144,6 +144,9 @@ auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type)
std::string(archive_error_string(aw));
}
} break;
+ case ArchiveType::TarAuto:
+ return std::string(
+ "ArchiveOps: Writing a tarball-type archive must be explicit!");
}
return std::nullopt; // success!
}
@@ -157,6 +160,7 @@ auto ArchiveOps::EnableReadFormats(archive* ar, ArchiveType type)
std::string(archive_error_string(ar));
}
} break;
+ case ArchiveType::TarAuto:
case ArchiveType::Tar:
case ArchiveType::TarGz:
case ArchiveType::TarBz2:
diff --git a/src/other_tools/utils/archive_ops.hpp b/src/other_tools/utils/archive_ops.hpp
index 6ad5b7c4..74fcf39c 100644
--- a/src/other_tools/utils/archive_ops.hpp
+++ b/src/other_tools/utils/archive_ops.hpp
@@ -25,7 +25,14 @@ using archive = struct archive;
using archive_entry = struct archive_entry;
}
-enum class ArchiveType : size_t { Zip, Tar, TarGz, TarBz2, TarXz };
+enum class ArchiveType : size_t {
+ Zip,
+ Tar, // uncompressed
+ TarGz,
+ TarBz2,
+ TarXz,
+ TarAuto, // autodetect tarball-type archives
+};
/// \brief Class handling archiving and unarchiving operations via libarchive
class ArchiveOps {
diff --git a/test/other_tools/utils/archive_usage.test.cpp b/test/other_tools/utils/archive_usage.test.cpp
index 68fe436d..59b09d8c 100644
--- a/test/other_tools/utils/archive_usage.test.cpp
+++ b/test/other_tools/utils/archive_usage.test.cpp
@@ -224,6 +224,8 @@ void enable_write_format_and_filter(archive* aw, ArchiveType type) {
REQUIRE(archive_write_set_format_pax_restricted(aw) == ARCHIVE_OK);
REQUIRE(archive_write_add_filter_xz(aw) == ARCHIVE_OK);
} break;
+ case ArchiveType::TarAuto:
+ return; // unused
}
}
@@ -247,6 +249,8 @@ void enable_read_format_and_filter(archive* ar, ArchiveType type) {
REQUIRE(archive_read_support_format_tar(ar) == ARCHIVE_OK);
REQUIRE(archive_read_support_filter_xz(ar) == ARCHIVE_OK);
} break;
+ case ArchiveType::TarAuto:
+ return; // unused
}
}