Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package karchive for openSUSE:Factory 
checked in at 2021-05-10 15:35:12
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/karchive (Old)
 and      /work/SRC/openSUSE:Factory/.karchive.new.2988 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "karchive"

Mon May 10 15:35:12 2021 rev:90 rq:891727 version:5.82.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/karchive/karchive.changes        2021-04-12 
12:35:45.953239879 +0200
+++ /work/SRC/openSUSE:Factory/.karchive.new.2988/karchive.changes      
2021-05-10 15:36:43.958191197 +0200
@@ -1,0 +2,12 @@
+Sat May  1 16:40:34 UTC 2021 - Christophe Giboudeaux <[email protected]>
+
+- Update to 5.82.0
+  * New feature release
+  * For more details please see:
+  * https://kde.org/announcements/frameworks/5/5.82.0
+- Changes since 5.81.0:
+  * Fix cmake detection for tar+zstd
+  * Implement KZstdFilter (kde#434577)
+  * Fix compile with uncommented debug
+
+-------------------------------------------------------------------

Old:
----
  karchive-5.81.0.tar.xz
  karchive-5.81.0.tar.xz.sig

New:
----
  karchive-5.82.0.tar.xz
  karchive-5.82.0.tar.xz.sig

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ karchive.spec ++++++
--- /var/tmp/diff_new_pack.dISh4V/_old  2021-05-10 15:36:44.466189131 +0200
+++ /var/tmp/diff_new_pack.dISh4V/_new  2021-05-10 15:36:44.470189114 +0200
@@ -17,7 +17,7 @@
 
 
 %define lname   libKF5Archive5
-%define _tar_path 5.81
+%define _tar_path 5.82
 # Full KF5 version (e.g. 5.33.0)
 %{!?_kf5_version: %global _kf5_version %{version}}
 # Last major and minor KF5 version (e.g. 5.33)
@@ -25,7 +25,7 @@
 # Only needed for the package signature condition
 %bcond_without lang
 Name:           karchive
-Version:        5.81.0
+Version:        5.82.0
 Release:        0
 Summary:        Qt 5 addon providing access to numerous types of archives
 License:        LGPL-2.1-or-later
@@ -41,10 +41,11 @@
 BuildRequires:  fdupes
 BuildRequires:  kf5-filesystem
 BuildRequires:  pkgconfig
-BuildRequires:  cmake(Qt5Core) >= 5.14.0
+BuildRequires:  cmake(Qt5Core) >= 5.15.0
 BuildRequires:  pkgconfig(bzip2)
 BuildRequires:  pkgconfig(liblzma)
 BuildRequires:  pkgconfig(zlib)
+BuildRequires:  pkgconfig(libzstd)
 
 %description
 KArchive provides classes for easy reading, creation and manipulation of
@@ -70,7 +71,7 @@
 Group:          Development/Libraries/KDE
 Requires:       %{lname} = %{version}
 Requires:       extra-cmake-modules
-Requires:       cmake(Qt5Core) >= 5.14.0
+Requires:       cmake(Qt5Core) >= 5.15.0
 
 %description devel
 KArchive provides classes for easy reading, creation and manipulation of
@@ -80,15 +81,15 @@
 GZip format, via a subclass of QIODevice. Development files
 
 %prep
-%setup -q
+%autosetup -p1
 
 %build
-  %cmake_kf5 -d build
-  %cmake_build
+%cmake_kf5 -d build
+%cmake_build
 
 %install
-  %kf5_makeinstall -C build
-  %fdupes %{buildroot}
+%kf5_makeinstall -C build
+%fdupes %{buildroot}
 
 %post -n %{lname} -p /sbin/ldconfig
 %postun -n %{lname} -p /sbin/ldconfig


++++++ karchive-5.81.0.tar.xz -> karchive-5.82.0.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/.gitignore 
new/karchive-5.82.0/.gitignore
--- old/karchive-5.81.0/.gitignore      2021-04-03 11:28:32.000000000 +0200
+++ new/karchive-5.82.0/.gitignore      2021-05-01 11:37:13.000000000 +0200
@@ -21,3 +21,6 @@
 .cmake/
 /.clang-format
 /compile_commands.json
+.clangd
+.idea
+/cmake-build*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/CMakeLists.txt 
new/karchive-5.82.0/CMakeLists.txt
--- old/karchive-5.81.0/CMakeLists.txt  2021-04-03 11:28:32.000000000 +0200
+++ new/karchive-5.82.0/CMakeLists.txt  2021-05-01 11:37:13.000000000 +0200
@@ -1,10 +1,10 @@
-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.6)
 
-set(KF_VERSION "5.81.0") # handled by release scripts
+set(KF_VERSION "5.82.0") # handled by release scripts
 project(KArchive VERSION ${KF_VERSION})
 
 include(FeatureSummary)
-find_package(ECM 5.81.0  NO_MODULE)
+find_package(ECM 5.82.0  NO_MODULE)
 set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake 
Modules." URL "https://commits.kde.org/extra-cmake-modules";)
 feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND 
FATAL_ON_MISSING_REQUIRED_PACKAGES)
 
@@ -18,7 +18,7 @@
 
 include(ECMGenerateExportHeader)
 
-set(REQUIRED_QT_VERSION 5.14.0)
+set(REQUIRED_QT_VERSION 5.15.0)
 find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
 
 find_package(ZLIB)
@@ -47,6 +47,12 @@
     ${ZLIB_INCLUDE_DIR}
 )
 
+find_package(PkgConfig)
+pkg_check_modules(LibZstd IMPORTED_TARGET "libzstd")
+add_feature_info(LibZstd LibZstd_FOUND
+                "Support for zstd compressed files and data streams"
+)
+
 include(ECMSetupVersion)
 include(ECMGenerateHeaders)
 include(ECMQtDeclareLoggingCategory)
@@ -63,7 +69,7 @@
     PACKAGE_VERSION_FILE 
"${CMAKE_CURRENT_BINARY_DIR}/KF5ArchiveConfigVersion.cmake"
     SOVERSION 5)
 add_definitions(-DQT_NO_FOREACH)
-add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050e00)
+add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00)
 
 add_subdirectory(src)
 if (BUILD_TESTING)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/CMakeLists.txt 
new/karchive-5.82.0/autotests/CMakeLists.txt
--- old/karchive-5.81.0/autotests/CMakeLists.txt        2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/autotests/CMakeLists.txt        2021-05-01 
11:37:13.000000000 +0200
@@ -55,4 +55,24 @@
             ${testDir}/kcompressiondevice_test.tar.xz examples
             WORKING_DIRECTORY ${topdir})
     endif()
+
+    if (LibZstd_FOUND)
+        # cmake doesn't support creating zstd files so run tar directly
+        # which is a bit annoying since not all tars support zstd either
+        # so we first check that the installed tar has the --zstd
+        # option and then we check that the zstd binary is available
+
+        execute_process(COMMAND tar --help OUTPUT_VARIABLE TAR_OUTPUT)
+        if (TAR_OUTPUT MATCHES ".*--zstd.*")
+            find_program(ZSTD_FOUND zstd)
+            if (ZSTD_FOUND)
+                add_custom_command(TARGET kcompressiondevicetest POST_BUILD
+                    COMMAND tar --zstd -cf
+                    ${testDir}/kcompressiondevice_test.tar.zst examples
+                    WORKING_DIRECTORY ${topdir})
+
+                target_compile_definitions(kcompressiondevicetest PRIVATE 
HAVE_ZSTD_SUPPORT_FILE)
+            endif()
+        endif()
+    endif()
 endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/karchivetest.cpp 
new/karchive-5.82.0/autotests/karchivetest.cpp
--- old/karchive-5.81.0/autotests/karchivetest.cpp      2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/autotests/karchivetest.cpp      2021-05-01 
11:37:13.000000000 +0200
@@ -25,7 +25,7 @@
 #include <kfilterdev.h>
 
 #ifndef Q_OS_WIN
-#include <errno.h>
+#include <cerrno>
 #include <unistd.h> // symlink
 #endif
 
@@ -359,6 +359,10 @@
     QTest::newRow(".tar.xz") << "karchivetest.tar.xz"
                              << "application/x-xz";
 #endif
+#if HAVE_ZSTD_SUPPORT
+    QTest::newRow(".tar.zst") << "karchivetest.tar.zst"
+                              << "application/zstd";
+#endif
 }
 
 /**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/kcompressiondevicetest.cpp 
new/karchive-5.82.0/autotests/kcompressiondevicetest.cpp
--- old/karchive-5.81.0/autotests/kcompressiondevicetest.cpp    2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/autotests/kcompressiondevicetest.cpp    2021-05-01 
11:37:13.000000000 +0200
@@ -46,6 +46,8 @@
         return "tar.bz2";
     case KCompressionDevice::Xz:
         return "tar.xz";
+    case KCompressionDevice::Zstd:
+        return "tar.zst";
     case KCompressionDevice::None:
         return QString();
     }
@@ -139,6 +141,15 @@
 #endif
 }
 
+void KCompressionDeviceTest::testZstdBufferedDevice()
+{
+#ifdef HAVE_ZSTD_SUPPORT_FILE
+    testBufferedDevice(KCompressionDevice::Zstd);
+#else
+    QSKIP("This test needs zstd support");
+#endif
+}
+
 void KCompressionDeviceTest::testWriteErrorOnOpen()
 {
     // GIVEN
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/kcompressiondevicetest.h 
new/karchive-5.82.0/autotests/kcompressiondevicetest.h
--- old/karchive-5.81.0/autotests/kcompressiondevicetest.h      2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/autotests/kcompressiondevicetest.h      2021-05-01 
11:37:13.000000000 +0200
@@ -39,6 +39,7 @@
     void testGZipBufferedDevice();
     void testBZip2BufferedDevice();
     void testXzBufferedDevice();
+    void testZstdBufferedDevice();
 
     void testWriteErrorOnOpen();
     void testWriteErrorOnClose();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/kfiltertest.cpp 
new/karchive-5.82.0/autotests/kfiltertest.cpp
--- old/karchive-5.81.0/autotests/kfiltertest.cpp       2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/autotests/kfiltertest.cpp       2021-05-01 
11:37:13.000000000 +0200
@@ -39,6 +39,7 @@
     pathbz2 = currentdir + "/test.bz2";
     pathxz = currentdir + "/test.xz";
     pathnone = currentdir + "/test.txt";
+    pathzstd = currentdir + "/test.zst";
 
     // warning, update the COMPAREs in test_block_write() if changing the test 
data...
     testData = "hello world\n";
@@ -79,6 +80,12 @@
     qDebug() << " -- test_block_write none -- ";
     test_block_write(pathnone, testData);
     QCOMPARE(QFileInfo(pathnone).size(), 12LL); // size of test.txt
+
+#if HAVE_ZSTD_SUPPORT
+    qDebug() << " -- test_block_write zstd -- ";
+    test_block_write(pathzstd, testData);
+    QCOMPARE(QFileInfo(pathzstd).size(), 24LL); // size of test.zst
+#endif
 }
 
 void KFilterTest::test_biggerWrites()
@@ -156,6 +163,10 @@
 #endif
     qDebug() << " -- test_block_read none -- ";
     test_block_read(pathnone);
+#if HAVE_ZSTD_SUPPORT
+    qDebug() << " -- test_block_read zstd -- ";
+    test_block_read(pathzstd);
+#endif
 }
 
 void KFilterTest::test_getch(const QString &fileName)
@@ -187,6 +198,10 @@
 #endif
     qDebug() << " -- test_getch none -- ";
     test_getch(pathnone);
+#if HAVE_ZSTD_SUPPORT
+    qDebug() << " -- test_getch zstd -- ";
+    test_getch(pathzstd);
+#endif
 }
 
 void KFilterTest::test_textstream(const QString &fileName)
@@ -216,6 +231,10 @@
 #endif
     qDebug() << " -- test_textstream none -- ";
     test_textstream(pathnone);
+#if HAVE_ZSTD_SUPPORT
+    qDebug() << " -- test_textstream zstd -- ";
+    test_textstream(pathzstd);
+#endif
 }
 
 void KFilterTest::test_readall(const QString &fileName, const QString 
&mimeType, const QByteArray &expectedData)
@@ -256,6 +275,11 @@
 
     qDebug() << " -- test_readall none -- ";
     test_readall(pathnone, QString::fromLatin1("text/plain"), testData);
+
+#if HAVE_ZSTD_SUPPORT
+    qDebug() << " -- test_readall zstd -- ";
+    test_readall(pathzstd, QString::fromLatin1("application/zstd"), testData);
+#endif
 }
 
 void KFilterTest::test_uncompressed()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/autotests/kfiltertest.h 
new/karchive-5.82.0/autotests/kfiltertest.h
--- old/karchive-5.81.0/autotests/kfiltertest.h 2021-04-03 11:28:32.000000000 
+0200
+++ new/karchive-5.82.0/autotests/kfiltertest.h 2021-05-01 11:37:13.000000000 
+0200
@@ -42,6 +42,7 @@
     QString pathbz2;
     QString pathxz;
     QString pathnone;
+    QString pathzstd;
     QByteArray testData;
 };
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/CMakeLists.txt 
new/karchive-5.82.0/src/CMakeLists.txt
--- old/karchive-5.81.0/src/CMakeLists.txt      2021-04-03 11:28:32.000000000 
+0200
+++ new/karchive-5.82.0/src/CMakeLists.txt      2021-05-01 11:37:13.000000000 
+0200
@@ -4,6 +4,7 @@
 endif()
 
 set(HAVE_XZ_SUPPORT ${LIBLZMA_FOUND})
+set(HAVE_ZSTD_SUPPORT ${LibZstd_FOUND})
 
 configure_file(config-compression.h.cmake 
${CMAKE_CURRENT_BINARY_DIR}/config-compression.h)
 add_definitions(-DQT_NO_CAST_FROM_ASCII)
@@ -20,6 +21,11 @@
     set(karchive_OPTIONAL_LIBS ${karchive_OPTIONAL_LIBS} ${LIBLZMA_LIBRARIES})
 endif()
 
+if (LibZstd_FOUND)
+    set(karchive_OPTIONAL_SRCS ${karchive_OPTIONAL_SRCS} kzstdfilter.cpp)
+    set(karchive_OPTIONAL_LIBS ${karchive_OPTIONAL_LIBS} PkgConfig::LibZstd)
+endif()
+
 
 set(karchive_SRCS
     karchive.cpp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/config-compression.h.cmake 
new/karchive-5.82.0/src/config-compression.h.cmake
--- old/karchive-5.81.0/src/config-compression.h.cmake  2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/src/config-compression.h.cmake  2021-05-01 
11:37:13.000000000 +0200
@@ -6,3 +6,6 @@
 /* Set to 1 if you have xz */
 #cmakedefine01 HAVE_XZ_SUPPORT
 
+/* Set to 1 if you have zstd */
+#cmakedefine01 HAVE_ZSTD_SUPPORT
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/karchive.cpp 
new/karchive-5.82.0/src/karchive.cpp
--- old/karchive-5.81.0/src/karchive.cpp        2021-04-03 11:28:32.000000000 
+0200
+++ new/karchive-5.82.0/src/karchive.cpp        2021-05-01 11:37:13.000000000 
+0200
@@ -20,7 +20,7 @@
 #include <QMap>
 #include <QStack>
 
-#include <errno.h>
+#include <cerrno>
 #include <stdio.h>
 #include <stdlib.h>
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kcompressiondevice.cpp 
new/karchive-5.82.0/src/kcompressiondevice.cpp
--- old/karchive-5.81.0/src/kcompressiondevice.cpp      2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/src/kcompressiondevice.cpp      2021-05-01 
11:37:13.000000000 +0200
@@ -20,6 +20,9 @@
 #if HAVE_XZ_SUPPORT
 #include "kxzfilter.h"
 #endif
+#if HAVE_ZSTD_SUPPORT
+#include "kzstdfilter.h"
+#endif
 
 #include <QDebug>
 #include <QFile>
@@ -88,6 +91,10 @@
 #endif
     case KCompressionDevice::None:
         return new KNoneFilter;
+#if HAVE_ZSTD_SUPPORT
+    case KCompressionDevice::Zstd:
+        return new KZstdFilter;
+#endif
     }
     return nullptr;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kcompressiondevice.h 
new/karchive-5.82.0/src/kcompressiondevice.h
--- old/karchive-5.81.0/src/kcompressiondevice.h        2021-04-03 
11:28:32.000000000 +0200
+++ new/karchive-5.82.0/src/kcompressiondevice.h        2021-05-01 
11:37:13.000000000 +0200
@@ -36,6 +36,7 @@
         BZip2,
         Xz,
         None,
+        Zstd, ///< @since 5.82
     };
 
     /**
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kfilterdev.cpp 
new/karchive-5.82.0/src/kfilterdev.cpp
--- old/karchive-5.81.0/src/kfilterdev.cpp      2021-04-03 11:28:32.000000000 
+0200
+++ new/karchive-5.82.0/src/kfilterdev.cpp      2021-05-01 11:37:13.000000000 
+0200
@@ -27,6 +27,11 @@
         return KCompressionDevice::Xz;
     }
 #endif
+#if HAVE_ZSTD_SUPPORT
+    if (fileName.endsWith(QLatin1String(".zst"), Qt::CaseInsensitive)) {
+        return KCompressionDevice::Zstd;
+    }
+#endif
     else {
         // not a warning, since this is called often with other mimetypes (see 
#88574)...
         // maybe we can avoid that though?
@@ -60,6 +65,11 @@
         return KCompressionDevice::Xz;
     }
 #endif
+#if HAVE_ZSTD_SUPPORT
+    if (mimeType == QLatin1String("application/zstd")) {
+        return KCompressionDevice::Zstd;
+    }
+#endif
     QMimeDatabase db;
     const QMimeType mime = db.mimeTypeForName(mimeType);
     if (mime.isValid()) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/ktar.cpp 
new/karchive-5.82.0/src/ktar.cpp
--- old/karchive-5.81.0/src/ktar.cpp    2021-04-03 11:28:32.000000000 +0200
+++ new/karchive-5.82.0/src/ktar.cpp    2021-05-01 11:37:13.000000000 +0200
@@ -29,6 +29,7 @@
 static const char application_bzip[] = "application/x-bzip";
 static const char application_lzma[] = "application/x-lzma";
 static const char application_xz[] = "application/x-xz";
+static const char application_zstd[] = "application/zstd";
 
 class Q_DECL_HIDDEN KTar::KTarPrivate
 {
@@ -108,6 +109,9 @@
         } else if 
(mime.inherits(QStringLiteral("application/x-xz-compressed-tar")) || 
mime.inherits(QString::fromLatin1(application_xz))) {
             // xz compressed tar file (with possibly invalid name), ask for xz 
filter
             d->mimetype = QString::fromLatin1(application_xz);
+        } else if 
(mime.inherits(QStringLiteral("application/x-zstd-compressed-tar")) || 
mime.inherits(QString::fromLatin1(application_zstd))) {
+            // zstd compressed tar file (with possibly invalid name), ask for 
zstd filter
+            d->mimetype = QString::fromLatin1(application_zstd);
         }
     }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kzip.cpp 
new/karchive-5.82.0/src/kzip.cpp
--- old/karchive-5.81.0/src/kzip.cpp    2021-04-03 11:28:32.000000000 +0200
+++ new/karchive-5.82.0/src/kzip.cpp    2021-05-01 11:37:13.000000000 +0200
@@ -664,8 +664,6 @@
             // offset, where the real data for uncompression starts
             uint dataoffset = localheaderoffset + 30 + localextralen + 
namelen; // comment only in central header
 
-            // qCDebug(KArchiveLog) << "esize: " << esize;
-            // qCDebug(KArchiveLog) << "eoffset: " << eoffset;
             // qCDebug(KArchiveLog) << "csize: " << csize;
 
             int os_madeby = (uchar)buffer[5];
@@ -828,8 +826,8 @@
             return false;
         }
         // qCDebug(KArchiveLog) << "closearchive setcrcandcsize: fileName:"
-        //    << it.current()->path()
-        //    << "encoding:" << it.current()->encoding();
+        //    << it.value()->path()
+        //    << "encoding:" << it.value()->encoding();
 
         uLong mycrc = it.value()->crc32();
         buffer[0] = char(mycrc); // crc checksum, at headerStart+14
@@ -859,8 +857,8 @@
     it.toFront();
     while (it.hasNext()) {
         it.next();
-        // qCDebug(KArchiveLog) << "fileName:" << it.current()->path()
-        //              << "encoding:" << it.current()->encoding();
+        // qCDebug(KArchiveLog) << "fileName:" << it.value()->path()
+        //              << "encoding:" << it.value()->encoding();
 
         QByteArray path = QFile::encodeName(it.value()->path());
 
@@ -1074,11 +1072,11 @@
     // qCDebug(KArchiveLog) << "fileName to write: " << name;
     while (it.hasNext()) {
         it.next();
-        // qCDebug(KArchiveLog) << "prepfileName: " << it.current()->path();
+        // qCDebug(KArchiveLog) << "prepfileName: " << it.value()->path();
         if (name == it.value()->path()) {
             // also remove from the parentDir
             parentDir->removeEntry(it.value());
-            // qCDebug(KArchiveLog) << "removing following entry: " << 
it.current()->path();
+            // qCDebug(KArchiveLog) << "removing following entry: " << 
it.value()->path();
             delete it.value();
             it.remove();
         }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kzstdfilter.cpp 
new/karchive-5.82.0/src/kzstdfilter.cpp
--- old/karchive-5.81.0/src/kzstdfilter.cpp     1970-01-01 01:00:00.000000000 
+0100
+++ new/karchive-5.82.0/src/kzstdfilter.cpp     2021-05-01 11:37:13.000000000 
+0200
@@ -0,0 +1,132 @@
+/* This file is part of the KDE libraries
+   SPDX-FileCopyrightText: 2021 Albert Astals Cid <[email protected]>
+
+   SPDX-License-Identifier: LGPL-2.0-or-later
+*/
+
+#include "kzstdfilter.h"
+#include "loggingcategory.h"
+
+#if HAVE_ZSTD_SUPPORT
+
+extern "C" {
+#include <zstd.h>
+}
+
+class Q_DECL_HIDDEN KZstdFilter::Private
+{
+public:
+    union {
+        ZSTD_CStream *cStream;
+        ZSTD_DStream *dStream;
+    };
+    int mode;
+    bool isInitialized = false;
+    ZSTD_inBuffer inBuffer;
+    ZSTD_outBuffer outBuffer;
+};
+
+KZstdFilter::KZstdFilter()
+    : d(new Private)
+{
+}
+
+KZstdFilter::~KZstdFilter()
+{
+}
+
+bool KZstdFilter::init(int mode)
+{
+    if (d->isInitialized) {
+        terminate();
+    }
+
+    d->inBuffer.size = 0;
+    d->inBuffer.pos = 0;
+
+    if (mode == QIODevice::ReadOnly) {
+        d->dStream = ZSTD_createDStream();
+    } else if (mode == QIODevice::WriteOnly) {
+        d->cStream = ZSTD_createCStream();
+    } else {
+        // qCWarning(KArchiveLog) << "Unsupported mode " << mode << ". Only 
QIODevice::ReadOnly and QIODevice::WriteOnly supported";
+        return false;
+    }
+    d->mode = mode;
+    d->isInitialized = true;
+    return true;
+}
+
+int KZstdFilter::mode() const
+{
+    return d->mode;
+}
+
+bool KZstdFilter::terminate()
+{
+    if (d->mode == QIODevice::ReadOnly) {
+        ZSTD_freeDStream(d->dStream);
+    } else if (d->mode == QIODevice::WriteOnly) {
+        ZSTD_freeCStream(d->cStream);
+    } else {
+        // qCWarning(KArchiveLog) << "Unsupported mode " << d->mode << ". Only 
QIODevice::ReadOnly and QIODevice::WriteOnly supported";
+        return false;
+    }
+    d->isInitialized = false;
+    return true;
+}
+
+void KZstdFilter::reset()
+{
+    terminate();
+    init(d->mode);
+}
+
+void KZstdFilter::setOutBuffer(char *data, uint maxlen)
+{
+    d->outBuffer.dst = data;
+    d->outBuffer.size = maxlen;
+    d->outBuffer.pos = 0;
+}
+
+void KZstdFilter::setInBuffer(const char *data, unsigned int size)
+{
+    d->inBuffer.src = data;
+    d->inBuffer.size = size;
+    d->inBuffer.pos = 0;
+}
+
+int KZstdFilter::inBufferAvailable() const
+{
+    return d->inBuffer.size - d->inBuffer.pos;
+}
+
+int KZstdFilter::outBufferAvailable() const
+{
+    return d->outBuffer.size - d->outBuffer.pos;
+}
+
+KZstdFilter::Result KZstdFilter::uncompress()
+{
+    // qCDebug(KArchiveLog) << "Calling ZSTD_decompressStream with avail_in=" 
<< inBufferAvailable() << " avail_out=" << outBufferAvailable();
+    const size_t result = ZSTD_decompressStream(d->dStream, &d->outBuffer, 
&d->inBuffer);
+    if (ZSTD_isError(result)) {
+        qCWarning(KArchiveLog) << "ZSTD_decompressStream returned" << result 
<< ZSTD_getErrorName(result);
+        return KFilterBase::Error;
+    }
+
+    return result == 0 ? KFilterBase::End : KFilterBase::Ok;
+}
+
+KZstdFilter::Result KZstdFilter::compress(bool finish)
+{
+    // qCDebug(KArchiveLog) << "Calling ZSTD_compressStream2 with avail_in=" 
<< inBufferAvailable() << " avail_out=" << outBufferAvailable();
+    const size_t result = ZSTD_compressStream2(d->cStream, &d->outBuffer, 
&d->inBuffer, finish ? ZSTD_e_end : ZSTD_e_flush);
+    if (ZSTD_isError(result)) {
+        return KFilterBase::Error;
+    }
+
+    return finish && result == 0 ? KFilterBase::End : KFilterBase::Ok;
+}
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/src/kzstdfilter.h 
new/karchive-5.82.0/src/kzstdfilter.h
--- old/karchive-5.81.0/src/kzstdfilter.h       1970-01-01 01:00:00.000000000 
+0100
+++ new/karchive-5.82.0/src/kzstdfilter.h       2021-05-01 11:37:13.000000000 
+0200
@@ -0,0 +1,54 @@
+/* This file is part of the KDE libraries
+   SPDX-FileCopyrightText: 2021 Albert Astals Cid <[email protected]>
+
+   SPDX-License-Identifier: LGPL-2.0-or-later
+*/
+
+#ifndef KZSTDFILTER_H
+#define KZSTDFILTER_H
+
+#include <config-compression.h>
+
+#if HAVE_ZSTD_SUPPORT
+
+#include "kfilterbase.h"
+
+#include <memory>
+
+/**
+ * Internal class used by KFilterDev
+ * @internal
+ */
+class KZstdFilter : public KFilterBase
+{
+public:
+    KZstdFilter();
+    ~KZstdFilter() override;
+
+    bool init(int) override;
+    int mode() const override;
+    bool terminate() override;
+    void reset() override;
+    bool readHeader() override
+    {
+        return true;
+    }
+    bool writeHeader(const QByteArray &) override
+    {
+        return true;
+    }
+    void setOutBuffer(char *data, uint maxlen) override;
+    void setInBuffer(const char *data, uint size) override;
+    int inBufferAvailable() const override;
+    int outBufferAvailable() const override;
+    Result uncompress() override;
+    Result compress(bool finish) override;
+
+private:
+    class Private;
+    const std::unique_ptr<Private> d;
+};
+
+#endif
+
+#endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/karchive-5.81.0/tests/kziptest.cpp 
new/karchive-5.82.0/tests/kziptest.cpp
--- old/karchive-5.81.0/tests/kziptest.cpp      2021-04-03 11:28:32.000000000 
+0200
+++ new/karchive-5.82.0/tests/kziptest.cpp      2021-05-01 11:37:13.000000000 
+0200
@@ -166,6 +166,24 @@
     return zip.close() ? 0 : 1 /*error*/;
 }
 
+static int doCreate(const QString &archiveName, const QStringList &fileNames)
+{
+    KZip zip(archiveName);
+    if (!zip.open(QIODevice::WriteOnly)) {
+        qWarning() << "Could not open" << archiveName << "for writing";
+        return 1;
+    }
+    for (const QString &fileName : fileNames) {
+        QFile f(fileName);
+        if (!f.open(QIODevice::ReadOnly)) {
+            qWarning() << "Could not open" << fileName << "for reading.";
+            return 1;
+        }
+        zip.writeFile(fileName, f.readAll());
+    }
+    return zip.close() ? 0 : 1 /*error*/;
+}
+
 static int doUpdate(const QString &archiveName, const QString &fileName)
 {
     KZip zip(archiveName);
@@ -256,6 +274,7 @@
             " ./kziptest list /path/to/existing_file.zip       tests listing 
an existing zip\n"
             " ./kziptest print-all file.zip                    prints contents 
of all files.\n"
             " ./kziptest print file.zip filename               prints contents 
of one file.\n"
+            " ./kziptest create file.zip filenames             create a new 
zip file with these files.\n"
             " ./kziptest update file.zip filename              update filename 
in file.zip.\n"
             " ./kziptest save file.zip                         save file.\n"
             " ./kziptest load file.zip                         load file.\n"
@@ -283,6 +302,13 @@
         return doCompress(QFile::decodeName(argv[2]));
     } else if (command == QLatin1String("read")) {
         return doUncompress(QFile::decodeName(argv[2]));
+    } else if (command == QLatin1String("create")) {
+        if (argc < 4) {
+            printf("usage: kziptest create archivename filenames");
+            return 1;
+        }
+        const QStringList fileNames = app.arguments().mid(3);
+        return doCreate(QFile::decodeName(argv[2]), fileNames);
     } else if (command == QLatin1String("update")) {
         if (argc != 4) {
             printf("usage: kziptest update archivename filename");

Reply via email to