diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-14 11:05:34 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-08-14 15:09:11 +0200 |
commit | d95a7a4bb8d00a2e994bee82f4f64b2ed1d9ec12 (patch) | |
tree | a58225968a9717887a774a0467933bde58129f1b /src/other_tools/utils | |
parent | 65886ff172190648c1114a9953c154f3f4821119 (diff) | |
download | justbuild-d95a7a4bb8d00a2e994bee82f4f64b2ed1d9ec12.tar.gz |
just-mr archives: Add 7zip support via autodetection option
Similarly to tarballs, an autodetection option for zip-like
archives is added to enable a unified handling of both traditional
zip and 7zip formats. Thus, for "zip" archives just-mr uses now
this autodetection option.
Diffstat (limited to 'src/other_tools/utils')
-rw-r--r-- | src/other_tools/utils/archive_ops.cpp | 14 | ||||
-rw-r--r-- | src/other_tools/utils/archive_ops.hpp | 3 |
2 files changed, 16 insertions, 1 deletions
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, |