diff options
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 3 | ||||
-rw-r--r-- | src/other_tools/utils/archive_ops.cpp | 14 | ||||
-rw-r--r-- | src/other_tools/utils/archive_ops.hpp | 3 | ||||
-rw-r--r-- | test/other_tools/utils/archive_usage.test.cpp | 2 |
4 files changed, 20 insertions, 2 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 5fb1bd88..64c3db75 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -35,7 +35,8 @@ namespace { ArchiveType::TarAuto, archive, dst_dir); } if (repo_type == "zip") { - return ArchiveOps::ExtractArchive(ArchiveType::Zip, archive, dst_dir); + return ArchiveOps::ExtractArchive( + ArchiveType::ZipAuto, 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 a0804abc..f0d02531 100644 --- a/src/other_tools/utils/archive_ops.cpp +++ b/src/other_tools/utils/archive_ops.cpp @@ -148,6 +148,10 @@ auto ArchiveOps::EnableWriteFormats(archive* aw, ArchiveType type) std::string(archive_error_string(aw)); } } break; + case ArchiveType::ZipAuto: { + return std::string( + "ArchiveOps: Writing a zip-like archive must be explicit"); + } case ArchiveType::Tar: case ArchiveType::TarGz: case ArchiveType::TarBz2: @@ -182,6 +186,16 @@ auto ArchiveOps::EnableReadFormats(archive* ar, ArchiveType type) std::string(archive_error_string(ar)); } } break; + case ArchiveType::ZipAuto: { + if (archive_read_support_format_7zip(ar) != ARCHIVE_OK) { + return std::string("ArchiveOps: ") + + std::string(archive_error_string(ar)); + } + if (archive_read_support_format_zip(ar) != ARCHIVE_OK) { + return std::string("ArchiveOps: ") + + std::string(archive_error_string(ar)); + } + } break; case ArchiveType::TarAuto: case ArchiveType::Tar: case ArchiveType::TarGz: diff --git a/src/other_tools/utils/archive_ops.hpp b/src/other_tools/utils/archive_ops.hpp index 94013f30..773115bc 100644 --- a/src/other_tools/utils/archive_ops.hpp +++ b/src/other_tools/utils/archive_ops.hpp @@ -28,7 +28,8 @@ using archive_entry = struct archive_entry; enum class ArchiveType : size_t { Zip, _7Zip, - Tar, // uncompressed + ZipAuto, // autodetect zip-like archives + Tar, // uncompressed TarGz, TarBz2, TarXz, diff --git a/test/other_tools/utils/archive_usage.test.cpp b/test/other_tools/utils/archive_usage.test.cpp index 542f05e1..09d080c5 100644 --- a/test/other_tools/utils/archive_usage.test.cpp +++ b/test/other_tools/utils/archive_usage.test.cpp @@ -256,6 +256,7 @@ 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_lzma(aw) == ARCHIVE_OK); } break; + case ArchiveType::ZipAuto: case ArchiveType::TarAuto: return; // unused } @@ -292,6 +293,7 @@ void enable_read_format_and_filter(archive* ar, ArchiveType type) { REQUIRE(archive_read_support_format_tar(ar) == ARCHIVE_OK); REQUIRE(archive_read_support_filter_lzma(ar) == ARCHIVE_OK); } break; + case ArchiveType::ZipAuto: case ArchiveType::TarAuto: return; // unused } |