Commit 12118a26 authored by Alexey Ivanov's avatar Alexey Ivanov 🐢 Committed by Elvis Angelaccio
Browse files

libzipplugin: support lzma xz for libzip 1.8.0+

parent b4e7ad8b
include(CheckSymbolExists)
set(SUPPORTED_LIBZIP_MIMETYPES "application/zip;")
set(INSTALLED_LIBZIP_PLUGINS "")
......@@ -15,10 +13,10 @@ ecm_qt_declare_logging_category(kerfuffle_libzip_SRCS
# double-quotes of the last mime must NOT be escaped.
set(SUPPORTED_MIMETYPES "application/zip")
# TODO: replace with version-based check once there is a new libzip release with zstd support
check_symbol_exists(ZIP_CM_ZSTD "zip.h" HAVE_ZIP_CM_ZSTD)
if (HAVE_ZIP_CM_ZSTD)
if(LibZip_VERSION VERSION_GREATER_EQUAL "1.8.0")
set(ZIP_CM_ZSTD_JSON_LINE "\"Zstd\": \"Zstd\",")
set(ZIP_CM_LZMA_JSON_LINE "\"LZMA\": \"LZMA\",")
set(ZIP_CM_XZ_JSON_LINE "\"XZ\": \"XZ\",")
endif()
find_package(ZLIB REQUIRED)
......
......@@ -90,6 +90,8 @@
"CompressionMethods": {
"BZip2": "BZip2",
@ZIP_CM_ZSTD_JSON_LINE@
@ZIP_CM_LZMA_JSON_LINE@
@ZIP_CM_XZ_JSON_LINE@
"Default": "Default",
"Deflate": "Deflate",
"Store": "Store"
......
......@@ -267,6 +267,14 @@ bool LibzipPlugin::writeEntry(zip_t *archive, const QString &file, const Archive
#ifdef ZIP_CM_ZSTD
} else if (options.compressionMethod() == QLatin1String("Zstd")) {
compMethod = ZIP_CM_ZSTD;
#endif
#ifdef ZIP_CM_LZMA
} else if (options.compressionMethod() == QLatin1String("LZMA")) {
compMethod = ZIP_CM_LZMA;
#endif
#ifdef ZIP_CM_XZ
} else if (options.compressionMethod() == QLatin1String("XZ")) {
compMethod = ZIP_CM_XZ;
#endif
} else if (options.compressionMethod() == QLatin1String("Store")) {
compMethod = ZIP_CM_STORE;
......@@ -335,12 +343,10 @@ bool LibzipPlugin::emitEntryForIndex(zip_t *archive, qlonglong index)
e->setProperty("method", QStringLiteral("BZip2"));
Q_EMIT compressionMethodFound(QStringLiteral("BZip2"));
break;
#ifdef ZIP_CM_ZSTD
case ZIP_CM_ZSTD:
e->setProperty("method", QStringLiteral("Zstd"));
Q_EMIT compressionMethodFound(QStringLiteral("Zstd"));
break;
#endif
break;
case ZIP_CM_LZMA:
e->setProperty("method", QStringLiteral("LZMA"));
Q_EMIT compressionMethodFound(QStringLiteral("LZMA"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment