Commit 3953484c authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

filter KIO: add zstd support

parent 7de1119c
Pipeline #69624 canceled with stage
......@@ -17,3 +17,6 @@ add_subdirectory(thumbnail)
if(KArchive_HAVE_LZMA)
add_subdirectory(xz)
endif()
if(KArchive_HAVE_ZSTD)
add_subdirectory(zstd)
endif()
########### install files ###############
kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kioslave5/zstd)
<?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>
......@@ -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;
......
......@@ -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
}
}
}
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