summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp6
-rw-r--r--src/other_tools/utils/archive_ops.cpp36
-rw-r--r--src/other_tools/utils/archive_ops.hpp8
-rw-r--r--test/end-to-end/just-mr/create_test_archives.cpp6
-rw-r--r--test/other_tools/utils/archive_usage.test.cpp42
5 files changed, 42 insertions, 56 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 {
diff --git a/test/end-to-end/just-mr/create_test_archives.cpp b/test/end-to-end/just-mr/create_test_archives.cpp
index 3fa6759a..f7223410 100644
--- a/test/end-to-end/just-mr/create_test_archives.cpp
+++ b/test/end-to-end/just-mr/create_test_archives.cpp
@@ -120,8 +120,8 @@ auto main() -> int {
auto anchor = FileSystemManager::ChangeDirectory(tmp_dir->GetPath());
// 2. create the archives wrt to current directory
std::optional<std::string> res{std::nullopt};
- res = ArchiveOps::CreateArchive(
- ArchiveType::kArchiveTypeZip, "zip_repo.zip", "root");
+ res =
+ ArchiveOps::CreateArchive(ArchiveType::Zip, "zip_repo.zip", "root");
if (res) {
Logger::Log(LogLevel::Error,
"Creating test zip archive failed with:\n{}",
@@ -129,7 +129,7 @@ auto main() -> int {
return 1;
}
res = ArchiveOps::CreateArchive(
- ArchiveType::kArchiveTypeTarGz, "tgz_repo.tar.gz", "root");
+ ArchiveType::TarGz, "tgz_repo.tar.gz", "root");
if (res) {
Logger::Log(LogLevel::Error,
"Creating test tar.gz archive failed with:\n{}",
diff --git a/test/other_tools/utils/archive_usage.test.cpp b/test/other_tools/utils/archive_usage.test.cpp
index 732798a8..0c55ad7c 100644
--- a/test/other_tools/utils/archive_usage.test.cpp
+++ b/test/other_tools/utils/archive_usage.test.cpp
@@ -348,7 +348,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
create_files(test_dir_tar);
res = ArchiveOps::CreateArchive(
- ArchiveType::kArchiveTypeTar, filename_tar, test_dir_tar, ".");
+ ArchiveType::Tar, filename_tar, test_dir_tar, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -357,8 +357,8 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
REQUIRE(FileSystemManager::RemoveDirectory(test_dir_tar,
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar));
- res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTar, filename_tar, ".");
+ res =
+ ArchiveOps::ExtractArchive(ArchiveType::Tar, filename_tar, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -389,10 +389,8 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
create_files(test_dir_tar_gz);
- res = ArchiveOps::CreateArchive(ArchiveType::kArchiveTypeTarGz,
- filename_tar_gz,
- test_dir_tar_gz,
- ".");
+ res = ArchiveOps::CreateArchive(
+ ArchiveType::TarGz, filename_tar_gz, test_dir_tar_gz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -402,7 +400,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_gz));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTarGz, filename_tar_gz, ".");
+ ArchiveType::TarGz, filename_tar_gz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -414,7 +412,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_gz));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTar, filename_tar_gz, ".");
+ ArchiveType::Tar, filename_tar_gz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -446,10 +444,8 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
create_files(test_dir_tar_bz2);
- res = ArchiveOps::CreateArchive(ArchiveType::kArchiveTypeTarBz2,
- filename_tar_bz2,
- test_dir_tar_bz2,
- ".");
+ res = ArchiveOps::CreateArchive(
+ ArchiveType::TarBz2, filename_tar_bz2, test_dir_tar_bz2, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -459,7 +455,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_bz2));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTarBz2, filename_tar_bz2, ".");
+ ArchiveType::TarBz2, filename_tar_bz2, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -471,7 +467,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_bz2));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTar, filename_tar_bz2, ".");
+ ArchiveType::Tar, filename_tar_bz2, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -503,10 +499,8 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
create_files(test_dir_tar_xz);
- res = ArchiveOps::CreateArchive(ArchiveType::kArchiveTypeTarXz,
- filename_tar_xz,
- test_dir_tar_xz,
- ".");
+ res = ArchiveOps::CreateArchive(
+ ArchiveType::TarXz, filename_tar_xz, test_dir_tar_xz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -516,7 +510,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_xz));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTarXz, filename_tar_xz, ".");
+ ArchiveType::TarXz, filename_tar_xz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -528,7 +522,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_tar_xz));
res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeTar, filename_tar_xz, ".");
+ ArchiveType::Tar, filename_tar_xz, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -561,7 +555,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
create_files(test_dir_zip);
res = ArchiveOps::CreateArchive(
- ArchiveType::kArchiveTypeZip, filename_zip, test_dir_zip, ".");
+ ArchiveType::Zip, filename_zip, test_dir_zip, ".");
if (res != std::nullopt) {
FAIL(*res);
}
@@ -570,8 +564,8 @@ TEST_CASE("ArchiveOps", "[archive_ops]") {
REQUIRE(FileSystemManager::RemoveDirectory(test_dir_zip,
/*recursively=*/true));
REQUIRE(FileSystemManager::CreateDirectory(test_dir_zip));
- res = ArchiveOps::ExtractArchive(
- ArchiveType::kArchiveTypeZip, filename_zip, ".");
+ res =
+ ArchiveOps::ExtractArchive(ArchiveType::Zip, filename_zip, ".");
if (res != std::nullopt) {
FAIL(*res);
}