Commit 9540de6f authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau Committed by Elvis Angelaccio
Browse files

Add support for single files compressed with zstd

BUG: 434540
parent 573f3b14
......@@ -92,5 +92,35 @@ if (LIBLZMA_FOUND)
set(INSTALLED_LIBSINGLEFILE_PLUGINS "${INSTALLED_LIBSINGLEFILE_PLUGINS}kerfuffle_libxz;")
endif (LIBLZMA_FOUND)
#
# Zstd files
#
# KArchive supports zstd since 5.82, KArchive_HAVE_ZSTD only available since 5.85
if(KF5Archive_VERSION VERSION_GREATER_EQUAL "5.85.0")
set(HAVE_ZSTD ${KArchive_HAVE_ZSTD})
else()
# repeat dependency check done by KArchive
find_package(PkgConfig)
pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd")
set(HAVE_ZSTD ${LibZstd_FOUND})
endif()
if (HAVE_ZSTD)
set(kerfuffle_libzstd_SRCS zstdplugin.cpp ${kerfuffle_singlefile_SRCS})
set(SUPPORTED_LIBSINGLEFILE_MIMETYPES "${SUPPORTED_LIBSINGLEFILE_MIMETYPES}application/zstd;")
set(SUPPORTED_MIMETYPES "application/zstd")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/kerfuffle_libzstd.json.cmake
${CMAKE_CURRENT_BINARY_DIR}/kerfuffle_libzstd.json)
kerfuffle_add_plugin(kerfuffle_libzstd ${kerfuffle_libzstd_SRCS})
target_link_libraries(kerfuffle_libzstd KF5::Archive)
set(INSTALLED_LIBSINGLEFILE_PLUGINS "${INSTALLED_LIBSINGLEFILE_PLUGINS}kerfuffle_libzstd;")
endif (HAVE_ZSTD)
set(SUPPORTED_ARK_MIMETYPES "${SUPPORTED_ARK_MIMETYPES}${SUPPORTED_LIBSINGLEFILE_MIMETYPES}" PARENT_SCOPE)
set(INSTALLED_KERFUFFLE_PLUGINS "${INSTALLED_KERFUFFLE_PLUGINS}${INSTALLED_LIBSINGLEFILE_PLUGINS}" PARENT_SCOPE)
{
"KPlugin": {
"Description": "Open and extract single files compressed with the zstd algorithm",
"Id": "kerfuffle_libzstd",
"MimeTypes": [
"@SUPPORTED_MIMETYPES@"
],
"Name": "Zstd plugin",
"Version": "@RELEASE_SERVICE_VERSION@"
},
"X-KDE-Priority": 100
}
/*
* Copyright (c) 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "zstdplugin.h"
#include "kerfuffle_export.h"
#include <QString>
#include <KPluginFactory>
K_PLUGIN_CLASS_WITH_JSON(LibZstdInterface, "kerfuffle_libzstd.json")
LibZstdInterface::LibZstdInterface(QObject *parent, const QVariantList & args)
: LibSingleFileInterface(parent, args)
{
m_mimeType = QStringLiteral( "application/zstd" );
m_possibleExtensions.append(QStringLiteral( ".zst" ));
}
LibZstdInterface::~LibZstdInterface()
{
}
#include "zstdplugin.moc"
/*
* Copyright (c) 2021 Friedrich W. H. Kossebau <kossebau@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ZSTDPLUGIN_H
#define ZSTDPLUGIN_H
#include "singlefileplugin.h"
class KERFUFFLE_EXPORT LibZstdInterface : public LibSingleFileInterface
{
Q_OBJECT
public:
LibZstdInterface(QObject *parent, const QVariantList &args);
~LibZstdInterface() override;
};
#endif // ZSTDPLUGIN_H
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