Git commit 3953484cdb1ca698d66a1f3114f4eb932f665589 by Friedrich W. H. Kossebau. Committed on 10/07/2021 at 11:13. Pushed by dfaure into branch 'release/21.08'.
filter KIO: add zstd support M +3 -0 doc/kioslave/CMakeLists.txt A +2 -0 doc/kioslave/zstd/CMakeLists.txt A +37 -0 doc/kioslave/zstd/index.docbook M +5 -2 filter/filter.cpp M +14 -0 filter/filter.json https://invent.kde.org/network/kio-extras/commit/3953484cdb1ca698d66a1f3114f4eb932f665589 diff --git a/doc/kioslave/CMakeLists.txt b/doc/kioslave/CMakeLists.txt index d9347dde..c34453a9 100644 --- a/doc/kioslave/CMakeLists.txt +++ b/doc/kioslave/CMakeLists.txt @@ -17,3 +17,6 @@ add_subdirectory(thumbnail) if(KArchive_HAVE_LZMA) add_subdirectory(xz) endif() +if(KArchive_HAVE_ZSTD) + add_subdirectory(zstd) +endif() diff --git a/doc/kioslave/zstd/CMakeLists.txt b/doc/kioslave/zstd/CMakeLists.txt new file mode 100644 index 00000000..3a03c123 --- /dev/null +++ b/doc/kioslave/zstd/CMakeLists.txt @@ -0,0 +1,2 @@ +########### install files ############### +kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kioslave5/zstd) diff --git a/doc/kioslave/zstd/index.docbook b/doc/kioslave/zstd/index.docbook new file mode 100644 index 00000000..3784b6ef --- /dev/null +++ b/doc/kioslave/zstd/index.docbook @@ -0,0 +1,37 @@ +<?xml version="1.0" ?> +<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" +"dtd/kdedbx45.dtd" [ +<!ENTITY % addindex "IGNORE"> +<!ENTITY % English "INCLUDE" > <!-- change language only here --> +]> + +<article lang="&language;" id="zstd"> +<title>zstd</title> +<articleinfo> +<authorgroup> +<author><firstname>Friedrich</firstname><othername>W. H.</othername><surname>Kossebau</surname></author> +<!-- TRANS:ROLES_OF_TRANSLATORS --> +</authorgroup> +</articleinfo> + +<para><command>zstd</command> is a compression program.</para> + +<para>The zstd kioslave is not directly usable, and is intended for use +as a filter. For example, the tar kioslave can filter a file through +the zstd kioslave, in order to display the contents of a <literal +role="extension">tar.zst</literal> file directly in a &konqueror; +window.</para> + +<para>If you click on a file compressed with a <literal +role="extension">zst</literal> extension in &konqueror;, this kioslave is +used to uncompress it and display it as a normal (uncompressed) +file.</para> + +<para>If you are a developer, and would like to use the zstd filter, you +can find documentation on using kioslaves at <ulink +url="http://techbase.kde.org">http://techbase.kde.org</ulink></para> + +<para> See the manual: <ulink url="man:/zstd">zstd</ulink>. +</para> + +</article> diff --git a/filter/filter.cpp b/filter/filter.cpp index 06907b98..8bf8b0b8 100644 --- a/filter/filter.cpp +++ b/filter/filter.cpp @@ -61,7 +61,10 @@ int kdemain( int argc, char ** argv) FilterProtocol::FilterProtocol( const QByteArray & protocol, const QByteArray &pool, const QByteArray &app ) : KIO::SlaveBase( protocol, pool, app ) { - QString mimetype = QString::fromLatin1("application/x-") + QString::fromLatin1(protocol); + const QString mimetype = + (protocol == "zstd") ? QStringLiteral("application/zstd") : + QLatin1String("application/x-") + QLatin1String(protocol.constData()); + #if KARCHIVE_VERSION >= QT_VERSION_CHECK(5, 85, 0) filter = KCompressionDevice::filterForCompressionType(KCompressionDevice::compressionTypeForMimeType( mimetype )); #else @@ -140,7 +143,7 @@ void FilterProtocol::get(const QUrl& url) const QString extension = QFileInfo(subURL.path()).suffix(); QMimeDatabase db; QMimeType mime; - if (extension == "gz" || extension == "bz" || extension == "bz2") { + if (extension == "gz" || extension == "bz" || extension == "bz2"|| extension == "zst") { QString baseName = subURL.path(); baseName.truncate(baseName.length() - extension.length() - 1 /*the dot*/); qDebug(KIO_FILTER_DEBUG) << "baseName=" << baseName; diff --git a/filter/filter.json b/filter/filter.json index e51cd3be..0899f83e 100644 --- a/filter/filter.json +++ b/filter/filter.json @@ -69,6 +69,20 @@ "protocol": "xz", "reading": true, "source": false + }, + "zstd": { + "Icon": "package-x-generic", + "X-DocPath": "kioslave5/zstd/index.html", + "archiveMimetype": [ + "application/zstd" + ], + "determineMimetypeFromExtension": true, + "exec": "kf5/kio/filter", + "input": "stream", + "output": "stream", + "protocol": "zstd", + "reading": true, + "source": false } } }