diff -Nru karchive-5.30.0/autotests/deprecatedtest.cpp karchive-5.31.0/autotests/deprecatedtest.cpp --- karchive-5.30.0/autotests/deprecatedtest.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/autotests/deprecatedtest.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -45,7 +45,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = dir->entries(); QCOMPARE(listing.count(), 1); QCOMPARE(listing.at(0), fileName); diff -Nru karchive-5.30.0/autotests/karchivetest.cpp karchive-5.31.0/autotests/karchivetest.cpp --- karchive-5.30.0/autotests/karchivetest.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/autotests/karchivetest.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -195,6 +195,28 @@ QCOMPARE(QString::fromLatin1(contents.constData()), QString::fromLatin1(arr.constData())); delete dev; + // test read/seek/peek work fine + f = dir->file(QStringLiteral("test1")); + dev = f->createDevice(); + contents = dev->peek(4); + QCOMPARE(contents, QByteArray("Hall")); + contents = dev->peek(2); + QCOMPARE(contents, QByteArray("Ha")); + dev->seek(2); + contents = dev->peek(2); + QCOMPARE(contents, QByteArray("ll")); + dev->seek(0); + contents = dev->read(2); + QCOMPARE(contents, QByteArray("Ha")); + contents = dev->peek(2); + QCOMPARE(contents, QByteArray("ll")); + dev->seek(1); + contents = dev->read(1); + QCOMPARE(contents, QByteArray("a")); + dev->seek(4); + contents = dev->read(1); + QCOMPARE(contents, QByteArray("o")); + const KArchiveEntry *e = dir->entry(QStringLiteral("mediumfile")); QVERIFY(e && e->isFile()); f = (KArchiveFile *)e; @@ -355,7 +377,7 @@ void KArchiveTest::testNullDevice() { - QIODevice *nil = 0; + QIODevice *nil = nullptr; QTest::ignoreMessage(QtWarningMsg, "KArchive: Null device specified"); KTar tar(nil); QVERIFY(!tar.open(QIODevice::ReadOnly)); @@ -475,7 +497,7 @@ QVERIFY(tar.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup | WithTime); @@ -651,7 +673,7 @@ QVERIFY(tar.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); QCOMPARE(listing[0], QString("mode=100644 user= group= path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000098 type=file size=3")); @@ -672,7 +694,7 @@ QVERIFY2(tar.open(QIODevice::ReadOnly), "global_header_test.tar.gz"); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); @@ -690,7 +712,7 @@ QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_prefix_test.tar.gz"); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); @@ -716,7 +738,7 @@ QVERIFY2(tar.open(QIODevice::ReadOnly), "tar_directory_forgotten.tar.gz"); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); @@ -734,7 +756,7 @@ QVERIFY2(tar.open(QIODevice::ReadOnly), qPrintable(tar.fileName())); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); //qDebug() << listing.join("\n"); @@ -752,7 +774,7 @@ QVERIFY(tar.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = tar.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), WithUserGroup); //qDebug() << listing.join("\n"); @@ -881,7 +903,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); // ZIP has no support for per-file user/group, so omit them from the listing const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); @@ -961,7 +983,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); QCOMPARE(listing[0], QString("mode=100644 path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000098 type=file size=3")); @@ -989,7 +1011,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); QCOMPARE(listing.count(), 1); @@ -1018,7 +1040,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); QCOMPARE(listing.count(), 1); @@ -1062,7 +1084,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const KArchiveEntry *e = dir->entry(file1); QVERIFY(e && e->isFile()); @@ -1093,7 +1115,7 @@ QVERIFY(zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QByteArray fileData("aaaaaaaaaaaaaaa"); @@ -1143,7 +1165,7 @@ KRcc rcc(rccFile); QVERIFY(rcc.open(QIODevice::ReadOnly)); const KArchiveDirectory *rootDir = rcc.directory(); - QVERIFY(rootDir != 0); + QVERIFY(rootDir != nullptr); const KArchiveEntry *rrEntry = rootDir->entry(QStringLiteral("runtime_resource")); QVERIFY(rrEntry && rrEntry->isDirectory()); const KArchiveDirectory *rrDir = static_cast(rrEntry); @@ -1219,7 +1241,7 @@ QVERIFY(k7zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = k7zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); #ifndef Q_OS_WIN @@ -1344,7 +1366,7 @@ QVERIFY(k7zip.open(QIODevice::ReadOnly)); const KArchiveDirectory *dir = k7zip.directory(); - QVERIFY(dir != 0); + QVERIFY(dir != nullptr); const QStringList listing = recursiveListEntries(dir, QLatin1String(""), 0); QCOMPARE(listing[0], QString("mode=100644 path=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa0000000098 type=file size=3")); diff -Nru karchive-5.30.0/CMakeLists.txt karchive-5.31.0/CMakeLists.txt --- karchive-5.30.0/CMakeLists.txt 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/CMakeLists.txt 2017-02-05 00:49:42.000000000 +0000 @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.0) -set(KF5_VERSION "5.30.0") # handled by release scripts +set(KF5_VERSION "5.31.0") # handled by release scripts project(KArchive VERSION ${KF5_VERSION}) include(FeatureSummary) -find_package(ECM 5.30.0 NO_MODULE) +find_package(ECM 5.31.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) @@ -18,7 +18,7 @@ include(GenerateExportHeader) -set(REQUIRED_QT_VERSION 5.5.0) +set(REQUIRED_QT_VERSION 5.6.0) find_package(Qt5Core ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) find_package(ZLIB) @@ -49,6 +49,7 @@ include(ECMSetupVersion) include(ECMGenerateHeaders) +include(ECMQtDeclareLoggingCategory) ecm_setup_version(PROJECT VARIABLE_PREFIX KARCHIVE diff -Nru karchive-5.30.0/debian/changelog karchive-5.31.0/debian/changelog --- karchive-5.30.0/debian/changelog 2017-02-01 18:34:20.000000000 +0000 +++ karchive-5.31.0/debian/changelog 2017-02-14 22:50:39.000000000 +0000 @@ -1,3 +1,11 @@ +karchive (5.31.0-0ubuntu1) zesty; urgency=medium + + * Pass '-fno-keep-inline-functions' to gcc in the acc test in order to + avoid possible spurious test failures. + * New upstream release (5.31.0) + + -- José Manuel Santamaría Lema Tue, 14 Feb 2017 22:50:39 +0000 + karchive (5.30.0-0ubuntu1) zesty; urgency=low * New upstream release (5.30.0) diff -Nru karchive-5.30.0/debian/control karchive-5.31.0/debian/control --- karchive-5.30.0/debian/control 2017-02-01 18:34:20.000000000 +0000 +++ karchive-5.31.0/debian/control 2017-02-14 22:50:39.000000000 +0000 @@ -5,7 +5,7 @@ Uploaders: Maximiliano Curia Build-Depends: cmake (>= 2.8.12), debhelper (>= 9), - extra-cmake-modules (>= 5.30.0~), + extra-cmake-modules (>= 5.31.0~), libbz2-dev, liblzma-dev, pkg-kde-tools (>= 0.15.16~), diff -Nru karchive-5.30.0/debian/libkf5archive-dev.acc.in karchive-5.31.0/debian/libkf5archive-dev.acc.in --- karchive-5.30.0/debian/libkf5archive-dev.acc.in 2017-02-01 18:34:20.000000000 +0000 +++ karchive-5.31.0/debian/libkf5archive-dev.acc.in 2017-02-14 22:50:39.000000000 +0000 @@ -1,4 +1,4 @@ - + @@ -15,6 +15,7 @@ -fPIC + -fno-keep-inline-functions - + \ No newline at end of file diff -Nru karchive-5.30.0/src/CMakeLists.txt karchive-5.31.0/src/CMakeLists.txt --- karchive-5.30.0/src/CMakeLists.txt 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/CMakeLists.txt 2017-02-05 00:49:42.000000000 +0000 @@ -35,6 +35,13 @@ krcc.cpp ) +ecm_qt_declare_logging_category(karchive_SRCS + HEADER loggingcategory.h + IDENTIFIER KArchiveLog + CATEGORY_NAME kf5.karchive + DEFAULT_SEVERITY Warning +) + add_library(KF5Archive ${karchive_SRCS} ${karchive_OPTIONAL_SRCS}) generate_export_header(KF5Archive BASE_NAME KArchive) add_library(KF5::Archive ALIAS KF5Archive) diff -Nru karchive-5.30.0/src/k7zip.cpp karchive-5.31.0/src/k7zip.cpp --- karchive-5.30.0/src/k7zip.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/k7zip.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -18,6 +18,7 @@ #include "k7zip.h" #include "karchive_p.h" +#include "loggingcategory.h" #include #include @@ -404,12 +405,12 @@ : q(parent) , packPos(0) , numPackStreams(0) - , buffer(0) + , buffer(nullptr) , pos(0) , end(0) , headerSize(0) , countSize(0) - , m_currentFile(0) + , m_currentFile(nullptr) { } @@ -483,7 +484,7 @@ digests.clear(); isAnti.clear(); - buffer = 0; + buffer = nullptr; pos = 0; end = 0; headerSize = 0; @@ -563,7 +564,7 @@ quint32 K7Zip::K7ZipPrivate::readUInt32() { if (!buffer || (quint64)(pos + 4) > end) { - qDebug() << "error size"; + qCDebug(KArchiveLog) << "error size"; return 0; } @@ -575,7 +576,7 @@ quint64 K7Zip::K7ZipPrivate::readUInt64() { if (!buffer || (quint64)(pos + 8) > end) { - qDebug() << "error size"; + qCDebug(KArchiveLog) << "error size"; return 0; } @@ -621,7 +622,7 @@ } } if (i == rem) { - qDebug() << "read string error"; + qCDebug(KArchiveLog) << "read string error"; return QString(); } rem = i; @@ -629,7 +630,7 @@ int len = (int)(rem / 2); if (len < 0 || (size_t)len * 2 != rem) { - qDebug() << "read string unsupported"; + qCDebug(KArchiveLog) << "read string unsupported"; return QString(); } @@ -725,7 +726,7 @@ Folder *K7Zip::K7ZipPrivate::folderItem() { if (!buffer) { - return 0; + return nullptr; } Folder *folder = new Folder; @@ -746,9 +747,9 @@ unsigned char coderInfo = readByte(); int codecIdSize = (coderInfo & 0xF); if (codecIdSize > 8) { - qDebug() << "unsupported codec id size"; + qCDebug(KArchiveLog) << "unsupported codec id size"; delete folder; - return 0; + return nullptr; } Folder::FolderInfo *info = new Folder::FolderInfo(); std::unique_ptr codecID(new unsigned char[codecIdSize]); @@ -780,10 +781,10 @@ } if ((coderInfo & 0x80) != 0) { - qDebug() << "unsupported"; + qCDebug(KArchiveLog) << "unsupported"; delete info; delete folder; - return 0; + return nullptr; } numInStreamsTotal += info->numInStreams; @@ -812,7 +813,7 @@ } if (folder->packedStreams.size() != 1) { delete folder; - return 0; + return nullptr; } } } @@ -831,7 +832,7 @@ if (external != 0) { int dataIndex = readNumber(); if (dataIndex < 0 /*|| dataIndex >= dataVector->Size()*/) { - qDebug() << "wrong data index"; + qCDebug(KArchiveLog) << "wrong data index"; return false; } @@ -862,7 +863,7 @@ packCRCs.clear(); if (!findAttribute(kSize)) { - qDebug() << "kSize not found"; + qCDebug(KArchiveLog) << "kSize not found"; return false; } @@ -899,7 +900,7 @@ } if (!findAttribute(kFolder)) { - qDebug() << "kFolder not found"; + qCDebug(KArchiveLog) << "kFolder not found"; return false; } @@ -917,18 +918,18 @@ case 1: { int dataIndex = readNumber(); if (dataIndex < 0 /*|| dataIndex >= dataVector->Size()*/) { - qDebug() << "wrong data index"; + qCDebug(KArchiveLog) << "wrong data index"; } // TODO : go to the new index break; } default: - qDebug() << "external error"; + qCDebug(KArchiveLog) << "external error"; return false; } if (!findAttribute(kCodersUnpackSize)) { - qDebug() << "kCodersUnpackSize not found"; + qCDebug(KArchiveLog) << "kCodersUnpackSize not found"; return false; } @@ -1133,7 +1134,7 @@ for (;;) { type = readByte(); if (type > ((quint32)1 << 30)) { - qDebug() << "type error"; + qCDebug(KArchiveLog) << "type error"; return false; } switch (type) { @@ -1141,32 +1142,32 @@ return true; case kPackInfo: { if (!readPackInfo()) { - qDebug() << "error during read pack information"; + qCDebug(KArchiveLog) << "error during read pack information"; return false; } break; } case kUnpackInfo: { if (!readUnpackInfo()) { - qDebug() << "error during read pack information"; + qCDebug(KArchiveLog) << "error during read pack information"; return false; } break; } case kSubStreamsInfo: { if (!readSubStreamsInfo()) { - qDebug() << "error during read substreams information"; + qCDebug(KArchiveLog) << "error during read substreams information"; return false; } break; } default: - qDebug() << "Wrong type"; + qCDebug(KArchiveLog) << "Wrong type"; return false; } } - qDebug() << "should not reach"; + qCDebug(KArchiveLog) << "should not reach"; return false; } @@ -1488,7 +1489,7 @@ quint64 unpackSize64 = folder->getUnpackSize();; size_t unpackSize = (size_t)unpackSize64; if (unpackSize != unpackSize64) { - qDebug() << "unsupported"; + qCDebug(KArchiveLog) << "unsupported"; return inflatedData; } @@ -1544,7 +1545,7 @@ dev->seek(startPos); quint64 n = dev->read(encodedBuffer.get(), size); if (n != (quint64)size) { - qDebug() << "Failed read next size, should read " << size << ", read " << n; + qCDebug(KArchiveLog) << "Failed read next size, should read " << size << ", read " << n; return inflatedData; } QByteArray deflatedData(encodedBuffer.get(), size); @@ -1557,7 +1558,7 @@ QVector inflatedDatas; QByteArray deflatedData; for (int j = 0; j < seqInStreams.size(); ++j) { - Folder::FolderInfo *coder = 0; + Folder::FolderInfo *coder = nullptr; if ((quint32)j != mainCoderIndex) { coder = folder->folderInfos[coderIndexes[j]]; } else { @@ -1566,13 +1567,13 @@ deflatedData = datas[seqInStreams[j]]; - KFilterBase *filter = 0; + KFilterBase *filter = nullptr; switch (coder->methodID) { case k_LZMA: filter = KCompressionDevice::filterForCompressionType(KCompressionDevice::Xz); if (!filter) { - qDebug() << "filter not found"; + qCDebug(KArchiveLog) << "filter not found"; return QByteArray(); } static_cast(filter)->init(QIODevice::ReadOnly, KXzFilter::LZMA, coder->properties); @@ -1580,7 +1581,7 @@ case k_LZMA2: filter = KCompressionDevice::filterForCompressionType(KCompressionDevice::Xz); if (!filter) { - qDebug() << "filter not found"; + qCDebug(KArchiveLog) << "filter not found"; return QByteArray(); } static_cast(filter)->init(QIODevice::ReadOnly, KXzFilter::LZMA2, coder->properties); @@ -1605,7 +1606,7 @@ case k_BCJ: filter = KCompressionDevice::filterForCompressionType(KCompressionDevice::Xz); if (!filter) { - qDebug() << "filter not found"; + qCDebug(KArchiveLog) << "filter not found"; return QByteArray(); } static_cast(filter)->init(QIODevice::ReadOnly, KXzFilter::BCJ, coder->properties); @@ -1619,7 +1620,7 @@ case k_BZip2: filter = KCompressionDevice::filterForCompressionType(KCompressionDevice::BZip2); if (!filter) { - qDebug() << "filter not found"; + qCDebug(KArchiveLog) << "filter not found"; return QByteArray(); } filter->init(QIODevice::ReadOnly); @@ -1646,7 +1647,7 @@ filter->setOutBuffer(outBuffer.data(), outBuffer.size()); result = filter->uncompress(); if (result == KFilterBase::Error) { - qDebug() << " decode error"; + qCDebug(KArchiveLog) << " decode error"; filter->terminate(); delete filter; return QByteArray(); @@ -1657,13 +1658,13 @@ inflatedDataTmp.append(outBuffer.data(), uncompressedBytes); if (result == KFilterBase::End) { - //qDebug() << "Finished unpacking"; + //qCDebug(KArchiveLog) << "Finished unpacking"; break; // Finished. } } if (result != KFilterBase::End && !filter->inBufferEmpty()) { - qDebug() << "decode failed result" << result; + qCDebug(KArchiveLog) << "decode failed result" << result; filter->terminate(); delete filter; return QByteArray(); @@ -1685,7 +1686,7 @@ if (folder->unpackCRCDefined) { quint32 crc = crc32(0, (Bytef *)(inflated.data()), unpackSize); if (crc != folder->unpackCRC) { - qDebug() << "wrong crc"; + qCDebug(KArchiveLog) << "wrong crc"; return QByteArray(); } } @@ -2090,7 +2091,7 @@ const int ret = flt.write(header); if (ret != header.size()) { - qDebug() << "write error write " << ret << "expected" << header.size(); + qCDebug(KArchiveLog) << "write error write " << ret << "expected" << header.size(); return encodedData; } @@ -2327,7 +2328,7 @@ int minor = header[7]; /*if (major > 0 || minor > 2) { - qDebug() << "wrong archive version"; + qCDebug(KArchiveLog) << "wrong archive version"; return false; }*/ @@ -2397,7 +2398,7 @@ if (external != 0) { int dataIndex = (int)d->readNumber(); if (dataIndex < 0) { - //qDebug() << "dataIndex error"; + //qCDebug(KArchiveLog) << "dataIndex error"; } d->buffer = decodedData.constData(); d->pos = 0; @@ -2515,7 +2516,7 @@ if (external != 0) { int dataIndex = d->readNumber(); if (dataIndex < 0 /*|| dataIndex >= dataVector->Size()*/) { - qDebug() << "wrong data index"; + qCDebug(KArchiveLog) << "wrong data index"; } // TODO : go to the new index @@ -2535,7 +2536,7 @@ if (external != 0) { int dataIndex = d->readNumber(); if (dataIndex < 0) { - qDebug() << "wrong data index"; + qCDebug(KArchiveLog) << "wrong data index"; } // TODO : go to the new index @@ -2673,14 +2674,14 @@ if (d->mTimesDefined[i]) { mTime = KArchivePrivate::time_tToDateTime(toTimeT(d->mTimes[i])); } else { - mTime = KArchivePrivate::time_tToDateTime(time(NULL)); + mTime = KArchivePrivate::time_tToDateTime(time(nullptr)); } if (fileInfo->isDir) { QString path = QDir::cleanPath(fileInfo->path); const KArchiveEntry *ent = rootDir()->entry(path); if (ent && ent->isDirectory()) { - e = 0; + e = nullptr; } else { e = new KArchiveDirectory(this, entryName, access, mTime, rootDir()->user(), rootDir()->group(), QString()/*symlink*/); } @@ -2689,7 +2690,7 @@ e = new K7ZipFileEntry(this, entryName, access, mTime, rootDir()->user(), rootDir()->group(), QString()/*symlink*/, pos, fileInfo->size, d->outData); } else { QString target = QFile::decodeName(d->outData.mid(pos, fileInfo->size)); - e = new K7ZipFileEntry(this, entryName, access, mTime, rootDir()->user(), rootDir()->group(), target, 0, 0, 0); + e = new K7ZipFileEntry(this, entryName, access, mTime, rootDir()->user(), rootDir()->group(), target, 0, 0, nullptr); } } @@ -2711,7 +2712,7 @@ { // Unnecessary check (already checked by KArchive::close()) if (!isOpen()) { - //qWarning() << "You must open the file before close it\n"; + //qCWarning(KArchiveLog) << "You must open the file before close it\n"; return false; } @@ -2841,7 +2842,7 @@ { d->m_currentFile->setSize(size); - d->m_currentFile = 0L; + d->m_currentFile = nullptr; return true; } @@ -2869,13 +2870,13 @@ { if (!isOpen()) { setErrorString(tr("Application error: 7-Zip file must be open before being written into")); - qWarning() << "doPrepareWriting failed: !isOpen()"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { setErrorString(tr("Application error: attempted to write into non-writable 7-Zip file")); - qWarning() << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; return false; } @@ -2912,12 +2913,12 @@ { if (!isOpen()) { setErrorString(tr("Application error: 7-Zip file must be open before being written into")); - qWarning() << "doWriteDir failed: !isOpen()"; + qCWarning(KArchiveLog) << "doWriteDir failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { - //qWarning() << "You must open the tar file for writing\n"; + //qCWarning(KArchiveLog) << "You must open the tar file for writing\n"; return false; } @@ -2949,13 +2950,13 @@ { if (!isOpen()) { setErrorString(tr("Application error: 7-Zip file must be open before being written into")); - qWarning() << "doWriteSymLink failed: !isOpen()"; + qCWarning(KArchiveLog) << "doWriteSymLink failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { setErrorString(tr("Application error: attempted to write into non-writable 7-Zip file")); - qWarning() << "doWriteSymLink failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doWriteSymLink failed: !(mode() & QIODevice::WriteOnly)"; return false; } @@ -2971,7 +2972,7 @@ } QByteArray encodedTarget = QFile::encodeName(target); - K7ZipFileEntry *e = new K7ZipFileEntry(this, fileName, perm, mtime, user, group, target, 0, 0, 0); + K7ZipFileEntry *e = new K7ZipFileEntry(this, fileName, perm, mtime, user, group, target, 0, 0, nullptr); d->outData.append(encodedTarget); parentDir->addEntry(e); diff -Nru karchive-5.30.0/src/karchive.cpp karchive-5.31.0/src/karchive.cpp --- karchive-5.30.0/src/karchive.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/karchive.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -22,6 +22,7 @@ #include "karchive.h" #include "karchive_p.h" #include "klimitediodevice_p.h" +#include "loggingcategory.h" #include // QT_STATBUF, QT_LSTAT @@ -57,7 +58,7 @@ : d(new KArchivePrivate) { if (fileName.isEmpty()) { - qWarning("KArchive: No file name specified"); + qCWarning(KArchiveLog) << "KArchive: No file name specified"; } d->fileName = fileName; // This constructor leaves the device set to 0. @@ -68,7 +69,7 @@ : d(new KArchivePrivate) { if (!dev) { - qWarning("KArchive: Null device specified"); + qCWarning(KArchiveLog) << "KArchive: Null device specified"; } d->dev = dev; } @@ -107,7 +108,7 @@ d->mode = mode; Q_ASSERT(!d->rootDir); - d->rootDir = 0; + d->rootDir = nullptr; return openArchive(mode); } @@ -118,7 +119,7 @@ case QIODevice::WriteOnly: if (!d->fileName.isEmpty()) { // The use of QSaveFile can't be done in the ctor (no mode known yet) - //qDebug() << "Writing to a file using QSaveFile"; + //qCDebug(KArchiveLog) << "Writing to a file using QSaveFile"; d->saveFile = new QSaveFile(d->fileName); if (!d->saveFile->open(QIODevice::WriteOnly)) { setErrorString( @@ -127,7 +128,7 @@ .arg(d->saveFile->errorString())); delete d->saveFile; - d->saveFile = 0; + d->saveFile = nullptr; return false; } d->dev = d->saveFile; @@ -175,16 +176,16 @@ if (d->saveFile) { closeSucceeded = d->saveFile->commit(); delete d->saveFile; - d->saveFile = 0; + d->saveFile = nullptr; } if (d->deviceOwned) { delete d->dev; // we created it ourselves in open() } delete d->rootDir; - d->rootDir = 0; + d->rootDir = nullptr; d->mode = QIODevice::NotOpen; - d->dev = 0; + d->dev = nullptr; return closeSucceeded; } @@ -269,7 +270,7 @@ if (!prepareWriting(destName, fileInfo.owner(), fileInfo.group(), size, fi.st_mode, fileInfo.lastRead(), fileInfo.lastModified(), fileInfo.created())) { - //qWarning() << " prepareWriting" << destName << "failed"; + //qCWarning(KArchiveLog) << " prepareWriting" << destName << "failed"; return false; } @@ -280,7 +281,7 @@ qint64 total = 0; while ((n = file.read(array.data(), array.size())) > 0) { if (!writeData(array.data(), n)) { - //qWarning() << "writeData failed"; + //qCWarning(KArchiveLog) << "writeData failed"; return false; } total += n; @@ -288,7 +289,7 @@ Q_ASSERT(total == size); if (!finishWriting(size)) { - //qWarning() << "finishWriting failed"; + //qCWarning(KArchiveLog) << "finishWriting failed"; return false; } return true; @@ -308,7 +309,7 @@ for (QStringList::ConstIterator it = files.begin(); it != files.end(); ++it) { if (*it != QLatin1String(".") && *it != QLatin1String("..")) { QString fileName = path + QLatin1Char('/') + *it; -// qDebug() << "storing " << fileName; +// qCDebug(KArchiveLog) << "storing " << fileName; QString dest = destName.isEmpty() ? *it : (destName + QLatin1Char('/') + *it); QFileInfo fileInfo(fileName); @@ -330,19 +331,19 @@ { const qint64 size = data.size(); if (!prepareWriting(name, user, group, size, perm, atime, mtime, ctime)) { - //qWarning() << "prepareWriting failed"; + //qCWarning(KArchiveLog) << "prepareWriting failed"; return false; } // Write data // Note: if data is null, don't call write, it would terminate the KCompressionDevice if (data.constData() && size && !writeData(data.constData(), size)) { - //qWarning() << "writeData failed"; + //qCWarning(KArchiveLog) << "writeData failed"; return false; } if (!finishWriting(size)) { - //qWarning() << "finishWriting failed"; + //qCWarning(KArchiveLog) << "finishWriting failed"; return false; } return true; @@ -436,7 +437,7 @@ KArchiveDirectory *KArchive::rootDir() { if (!d->rootDir) { - //qDebug() << "Making root dir "; + //qCDebug(KArchiveLog) << "Making root dir "; QString username = ::getCurrentUserName(); QString groupname = ::getCurrentGroupName(); @@ -447,9 +448,9 @@ KArchiveDirectory *KArchive::findOrCreate(const QString &path) { - //qDebug() << path; + //qCDebug(KArchiveLog) << path; if (path.isEmpty() || path == QLatin1String("/") || path == QLatin1String(".")) { // root dir => found - //qDebug() << "returning rootdir"; + //qCDebug(KArchiveLog) << "returning rootdir"; return rootDir(); } // Important note : for tar files containing absolute paths @@ -462,12 +463,12 @@ const KArchiveEntry *ent = rootDir()->entry(path); if (ent) { if (ent->isDirectory()) - //qDebug() << "found it"; + //qCDebug(KArchiveLog) << "found it"; { const KArchiveDirectory *dir = static_cast(ent); return const_cast(dir); } else { - //qWarning() << "Found" << path << "but it's not a directory"; + //qCWarning(KArchiveLog) << "Found" << path << "but it's not a directory"; } } @@ -484,7 +485,7 @@ parent = findOrCreate(left); // recursive call... until we find an existing dir. } - //qDebug() << "found parent " << parent->name() << " adding " << dirname << " to ensure " << path; + //qCDebug(KArchiveLog) << "found parent " << parent->name() << " adding " << dirname << " to ensure " << path; // Found -> add the missing piece KArchiveDirectory *e = new KArchiveDirectory(this, dirname, d->rootDir->permissions(), d->rootDir->date(), d->rootDir->user(), @@ -533,8 +534,8 @@ if (saveFile) { saveFile->cancelWriting(); delete saveFile; - saveFile = 0; - dev = 0; + saveFile = nullptr; + dev = nullptr; } } @@ -681,7 +682,7 @@ { bool ok = archive()->device()->seek(d->pos); if (!ok) { - //qWarning() << "Failed to sync to" << d->pos << "to read" << name(); + //qCWarning(KArchiveLog) << "Failed to sync to" << d->pos << "to read" << name(); } // Read content @@ -802,11 +803,11 @@ const QString left = name.left(pos); const QString right = name.mid(pos + 1); - //qDebug() << "left=" << left << "right=" << right; + //qCDebug(KArchiveLog) << "left=" << left << "right=" << right; const KArchiveEntry *e = d->entries.value(left); if (!e || !e->isDirectory()) { - return 0; + return nullptr; } return static_cast(e)->entry(right); } @@ -820,13 +821,13 @@ if (e && e->isFile()) { return static_cast(e); } - return 0; + return nullptr; } void KArchiveDirectory::addEntry(KArchiveEntry *entry) { if (d->entries.value(entry->name())) { - /*qWarning() << "directory " << name() + /*qCWarning(KArchiveLog) << "directory " << name() << "has entry" << entry->name() << "already";*/ delete entry; return; @@ -843,12 +844,12 @@ QHash::Iterator it = d->entries.find(entry->name()); // nothing removed? if (it == d->entries.end()) { - qWarning() << "directory " << name() + qCWarning(KArchiveLog) << "directory " << name() << "has no entry with name " << entry->name(); return; } if (it.value() != entry) { - qWarning() << "directory " << name() + qCWarning(KArchiveLog) << "directory " << name() << "has another entry for name " << entry->name(); return; } @@ -886,7 +887,7 @@ // otherwise put file under root position in extraction folder QString curDirName = dirNameStack.pop(); if (!QDir(curDirName).absolutePath().startsWith(destDir)) { - qWarning() << "Attempted export into folder" << curDirName + qCWarning(KArchiveLog) << "Attempted export into folder" << curDirName << "which is outside of the extraction root folder" << destDir << "." << "Changing export of contained files to extraction root folder."; curDirName = destDir; @@ -909,7 +910,7 @@ #endif QFile symLinkTarget(curEntry->symLinkTarget()); if (!symLinkTarget.link(linkName)) { - //qDebug() << "symlink(" << curEntry->symLinkTarget() << ',' << linkName << ") failed:" << strerror(errno); + //qCDebug(KArchiveLog) << "symlink(" << curEntry->symLinkTarget() << ',' << linkName << ") failed:" << strerror(errno); } } else { if (curEntry->isFile()) { diff -Nru karchive-5.30.0/src/karchive_p.h karchive-5.31.0/src/karchive_p.h --- karchive-5.30.0/src/karchive_p.h 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/karchive_p.h 2017-02-05 00:49:42.000000000 +0000 @@ -30,9 +30,9 @@ public: KArchivePrivate() - : rootDir(0) - , saveFile(0) - , dev(0) + : rootDir(nullptr) + , saveFile(nullptr) + , dev(nullptr) , fileName() , mode(QIODevice::NotOpen) , deviceOwned(false) diff -Nru karchive-5.30.0/src/kar.cpp karchive-5.31.0/src/kar.cpp --- karchive-5.30.0/src/kar.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kar.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -18,6 +18,7 @@ #include "kar.h" #include "karchive_p.h" +#include "loggingcategory.h" #include #include @@ -61,14 +62,14 @@ qint64, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to AR file")); - qWarning() << "doPrepareWriting not implemented for KAr"; + qCWarning(KArchiveLog) << "doPrepareWriting not implemented for KAr"; return false; } bool KAr::doFinishWriting(qint64) { setErrorString(tr("Cannot write to AR file")); - qWarning() << "doFinishWriting not implemented for KAr"; + qCWarning(KArchiveLog) << "doFinishWriting not implemented for KAr"; return false; } @@ -76,7 +77,7 @@ mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to AR file")); - qWarning() << "doWriteDir not implemented for KAr"; + qCWarning(KArchiveLog) << "doWriteDir not implemented for KAr"; return false; } @@ -84,7 +85,7 @@ const QString &, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to AR file")); - qWarning() << "doWriteSymLink not implemented for KAr"; + qCWarning(KArchiveLog) << "doWriteSymLink not implemented for KAr"; return false; } @@ -111,7 +112,7 @@ return false; } - char *ar_longnames = 0; + char *ar_longnames = nullptr; while (! dev->atEnd()) { QByteArray ar_header; ar_header.resize(61); @@ -119,7 +120,7 @@ dev->seek(dev->pos() + (2 - (dev->pos() % 2)) % 2); // Ar headers are padded to byte boundary if (dev->read(ar_header.data(), 60) != 60) { // Read ar header - //qWarning() << "Couldn't read header"; + //qCWarning(KArchiveLog) << "Couldn't read header"; delete[] ar_longnames; //return false; return true; // Probably EOF / trailing junk @@ -146,13 +147,13 @@ ar_longnames[size] = '\0'; dev->read(ar_longnames, size); skip_entry = true; - //qDebug() << "Read in longnames entry"; + //qCDebug(KArchiveLog) << "Read in longnames entry"; } else if (name.mid(1, 1) == " ") { // Symbol table entry - //qDebug() << "Skipped symbol entry"; + //qCDebug(KArchiveLog) << "Skipped symbol entry"; dev->seek(dev->pos() + size); skip_entry = true; } else { // Longfilename - //qDebug() << "Longfilename #" << name.mid(1, 15).toInt(); + //qCDebug(KArchiveLog) << "Longfilename #" << name.mid(1, 15).toInt(); if (! ar_longnames) { setErrorString(tr("Invalid longfilename reference")); delete[] ar_longnames; @@ -168,7 +169,7 @@ name = name.trimmed(); // Process filename name.replace('/', QByteArray()); - //qDebug() << "Filename: " << name << " Size: " << size; + //qCDebug(KArchiveLog) << "Filename: " << name << " Size: " << size; KArchiveEntry *entry = new KArchiveFile(this, QString::fromLocal8Bit(name.constData()), mode, KArchivePrivate::time_tToDateTime(date), rootDir()->user(), rootDir()->group(), /*symlink*/ QString(), diff -Nru karchive-5.30.0/src/kbzip2filter.cpp karchive-5.31.0/src/kbzip2filter.cpp --- karchive-5.30.0/src/kbzip2filter.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kbzip2filter.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -18,6 +18,7 @@ */ #include "kbzip2filter.h" +#include "loggingcategory.h" #include @@ -75,22 +76,22 @@ terminate(); } - d->zStream.next_in = 0; + d->zStream.next_in = nullptr; d->zStream.avail_in = 0; if (mode == QIODevice::ReadOnly) { const int result = bzDecompressInit(&d->zStream, 0, 0); if (result != BZ_OK) { - //qDebug() << "bzDecompressInit returned " << result; + //qCDebug(KArchiveLog) << "bzDecompressInit returned " << result; return false; } } else if (mode == QIODevice::WriteOnly) { const int result = bzCompressInit(&d->zStream, 5, 0, 0); if (result != BZ_OK) { - //qDebug() << "bzDecompressInit returned " << result; + //qCDebug(KArchiveLog) << "bzDecompressInit returned " << result; return false; } } else { - //qWarning() << "Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; + //qCWarning(KArchiveLog) << "Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; return false; } d->mode = mode; @@ -108,17 +109,17 @@ if (d->mode == QIODevice::ReadOnly) { const int result = bzDecompressEnd(&d->zStream); if (result != BZ_OK) { - //qDebug() << "bzDecompressEnd returned " << result; + //qCDebug(KArchiveLog) << "bzDecompressEnd returned " << result; return false; } } else if (d->mode == QIODevice::WriteOnly) { const int result = bzCompressEnd(&d->zStream); if (result != BZ_OK) { - //qDebug() << "bzCompressEnd returned " << result; + //qCDebug(KArchiveLog) << "bzCompressEnd returned " << result; return false; } } else { - //qWarning() << "Unsupported mode " << d->mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; + //qCWarning(KArchiveLog) << "Unsupported mode " << d->mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; return false; } d->isInitialized = false; @@ -156,10 +157,10 @@ KBzip2Filter::Result KBzip2Filter::uncompress() { - //qDebug() << "Calling bzDecompress with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + //qCDebug(KArchiveLog) << "Calling bzDecompress with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); int result = bzDecompress(&d->zStream); if (result < BZ_OK) { - qWarning() << "bzDecompress returned" << result; + qCWarning(KArchiveLog) << "bzDecompress returned" << result; } switch (result) { @@ -174,7 +175,7 @@ KBzip2Filter::Result KBzip2Filter::compress(bool finish) { - //qDebug() << "Calling bzCompress with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + //qCDebug(KArchiveLog) << "Calling bzCompress with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); int result = bzCompress(&d->zStream, finish ? BZ_FINISH : BZ_RUN); switch (result) { @@ -185,11 +186,11 @@ return KFilterBase::Ok; break; case BZ_STREAM_END: - //qDebug() << " bzCompress returned " << result; + //qCDebug(KArchiveLog) << " bzCompress returned " << result; return KFilterBase::End; break; default: - //qDebug() << " bzCompress returned " << result; + //qCDebug(KArchiveLog) << " bzCompress returned " << result; return KFilterBase::Error; break; } diff -Nru karchive-5.30.0/src/kcompressiondevice.cpp karchive-5.31.0/src/kcompressiondevice.cpp --- karchive-5.30.0/src/kcompressiondevice.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kcompressiondevice.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -18,6 +18,7 @@ */ #include "kcompressiondevice.h" +#include "loggingcategory.h" #include #include "kfilterbase.h" #include @@ -48,6 +49,7 @@ , bOpenedUnderlyingDevice(false) , bIgnoreData(false) , type(KCompressionDevice::None) + , deviceReadPos(0) { } bool bNeedHeader; @@ -59,6 +61,7 @@ KFilterBase::Result result; KFilterBase *filter; KCompressionDevice::CompressionType type; + qint64 deviceReadPos; }; KFilterBase *KCompressionDevice::filterForCompressionType(KCompressionDevice::CompressionType type) @@ -81,7 +84,7 @@ case KCompressionDevice::None: return new KNoneFilter; } - return 0; + return nullptr; } KCompressionDevice::KCompressionDevice(QIODevice *inputDevice, bool autoDeleteInputDevice, CompressionType type) @@ -125,11 +128,11 @@ bool KCompressionDevice::open(QIODevice::OpenMode mode) { if (isOpen()) { - //qWarning() << "KCompressionDevice::open: device is already open"; + //qCWarning(KArchiveLog) << "KCompressionDevice::open: device is already open"; return true; // QFile returns false, but well, the device -is- open... } d->bOpenedUnderlyingDevice = false; - //qDebug() << mode; + //qCDebug(KArchiveLog) << mode; if (mode == QIODevice::ReadOnly) { d->buffer.resize(0); } else { @@ -138,7 +141,7 @@ } if (!d->filter->device()->isOpen()) { if (!d->filter->device()->open(mode)) { - //qWarning() << "KCompressionDevice::open: Couldn't open underlying device"; + //qCWarning(KArchiveLog) << "KCompressionDevice::open: Couldn't open underlying device"; return false; } d->bOpenedUnderlyingDevice = true; @@ -159,12 +162,12 @@ return; } if (d->filter->mode() == QIODevice::WriteOnly) { - write(0L, 0); // finish writing + write(nullptr, 0); // finish writing } - //qDebug() << "Calling terminate()."; + //qCDebug(KArchiveLog) << "Calling terminate()."; if (!d->filter->terminate()) { - //qWarning() << "KCompressionDevice::close: terminate returned an error"; + //qCWarning(KArchiveLog) << "KCompressionDevice::close: terminate returned an error"; } if (d->bOpenedUnderlyingDevice) { d->filter->device()->close(); @@ -174,28 +177,37 @@ bool KCompressionDevice::seek(qint64 pos) { - qint64 ioIndex = this->pos(); // current position - if (ioIndex == pos) { - return true; + if (d->deviceReadPos == pos) { + return QIODevice::seek(pos); } - //qDebug() << "seek(" << pos << ") called, current pos=" << ioIndex; + //qCDebug(KArchiveLog) << "seek(" << pos << ") called, current pos=" << ioIndex; Q_ASSERT(d->filter->mode() == QIODevice::ReadOnly); if (pos == 0) { + if (!QIODevice::seek(pos)) + return false; + // We can forget about the cached data d->bNeedHeader = !d->bSkipHeaders; d->result = KFilterBase::Ok; - d->filter->setInBuffer(0L, 0); + d->filter->setInBuffer(nullptr, 0); d->filter->reset(); - QIODevice::seek(pos); + d->deviceReadPos = 0; return d->filter->device()->reset(); } qint64 bytesToRead; - if (ioIndex < pos) { // we can start from here - bytesToRead = pos - ioIndex; + if (d->deviceReadPos < pos) { // we can start from here + bytesToRead = pos - d->deviceReadPos; + // Since we're going to do a read() below + // we need to reset the internal QIODevice pos to the real position we are + // so that after read() we are indeed pointing to the pos seek + // asked us to be in + if (!QIODevice::seek(d->deviceReadPos)) { + return false; + } } else { // we have to start from 0 ! Ugly and slow, but better than the previous // solution (KTarGz was allocating everything into memory) @@ -205,12 +217,11 @@ bytesToRead = pos; } - //qDebug() << "reading " << bytesToRead << " dummy bytes"; + //qCDebug(KArchiveLog) << "reading " << bytesToRead << " dummy bytes"; QByteArray dummy(qMin(bytesToRead, qint64(3 * BUFFER_SIZE)), 0); d->bIgnoreData = true; const bool result = (read(dummy.data(), bytesToRead) == bytesToRead); d->bIgnoreData = false; - QIODevice::seek(pos); return result; } @@ -224,7 +235,7 @@ qint64 KCompressionDevice::readData(char *data, qint64 maxlen) { Q_ASSERT(d->filter->mode() == QIODevice::ReadOnly); - //qDebug() << "maxlen=" << maxlen; + //qCDebug(KArchiveLog) << "maxlen=" << maxlen; KFilterBase *filter = d->filter; uint dataReceived = 0; @@ -257,7 +268,7 @@ // Request data from underlying device int size = filter->device()->read(d->buffer.data(), d->buffer.size()); - //qDebug() << "got" << size << "bytes from device"; + //qCDebug(KArchiveLog) << "got" << size << "bytes from device"; if (size) { filter->setInBuffer(d->buffer.data(), size); } else { @@ -273,15 +284,15 @@ d->result = filter->uncompress(); if (d->result == KFilterBase::Error) { - //qWarning() << "KCompressionDevice: Error when uncompressing data"; + //qCWarning(KArchiveLog) << "KCompressionDevice: Error when uncompressing data"; break; } // We got that much data since the last time we went here uint outReceived = availOut - filter->outBufferAvailable(); - //qDebug() << "avail_out = " << filter->outBufferAvailable() << " result=" << d->result << " outReceived=" << outReceived; + //qCDebug(KArchiveLog) << "avail_out = " << filter->outBufferAvailable() << " result=" << d->result << " outReceived=" << outReceived; if (availOut < uint(filter->outBufferAvailable())) { - //qWarning() << " last availOut " << availOut << " smaller than new avail_out=" << filter->outBufferAvailable() << " !"; + //qCWarning(KArchiveLog) << " last availOut " << availOut << " smaller than new avail_out=" << filter->outBufferAvailable() << " !"; } dataReceived += outReceived; @@ -303,6 +314,7 @@ filter->setOutBuffer(data, availOut); } + d->deviceReadPos += dataReceived; return dataReceived; } @@ -315,7 +327,7 @@ return 0; } - bool finish = (data == 0L); + bool finish = (data == nullptr); if (!finish) { filter->setInBuffer(data, len); if (d->bNeedHeader) { @@ -331,7 +343,7 @@ d->result = filter->compress(finish); if (d->result == KFilterBase::Error) { - //qWarning() << "KCompressionDevice: Error when compressing data"; + //qCWarning(KArchiveLog) << "KCompressionDevice: Error when compressing data"; // What to do ? break; } @@ -341,30 +353,30 @@ // We got that much data since the last time we went here uint wrote = availIn - filter->inBufferAvailable(); - //qDebug() << " Wrote everything for now. avail_in=" << filter->inBufferAvailable() << "result=" << d->result << "wrote=" << wrote; + //qCDebug(KArchiveLog) << " Wrote everything for now. avail_in=" << filter->inBufferAvailable() << "result=" << d->result << "wrote=" << wrote; // Move on in the input buffer data += wrote; dataWritten += wrote; availIn = len - dataWritten; - //qDebug() << " availIn=" << availIn << "dataWritten=" << dataWritten << "pos=" << pos(); + //qCDebug(KArchiveLog) << " availIn=" << availIn << "dataWritten=" << dataWritten << "pos=" << pos(); if (availIn > 0) { filter->setInBuffer(data, availIn); } } if (filter->outBufferFull() || (d->result == KFilterBase::End) || finish) { - //qDebug() << " writing to underlying. avail_out=" << filter->outBufferAvailable(); + //qCDebug(KArchiveLog) << " writing to underlying. avail_out=" << filter->outBufferAvailable(); int towrite = d->buffer.size() - filter->outBufferAvailable(); if (towrite > 0) { // Write compressed data to underlying device int size = filter->device()->write(d->buffer.data(), towrite); if (size != towrite) { - //qWarning() << "KCompressionDevice::write. Could only write " << size << " out of " << towrite << " bytes"; + //qCWarning(KArchiveLog) << "KCompressionDevice::write. Could only write " << size << " out of " << towrite << " bytes"; return 0; // indicate an error (happens on disk full) } - //qDebug() << " wrote " << size << " bytes"; + //qCDebug(KArchiveLog) << " wrote " << size << " bytes"; } if (d->result == KFilterBase::End) { Q_ASSERT(finish); // hopefully we don't get end before finishing diff -Nru karchive-5.30.0/src/kfilterbase.cpp karchive-5.31.0/src/kfilterbase.cpp --- karchive-5.30.0/src/kfilterbase.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kfilterbase.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -26,7 +26,7 @@ public: KFilterBasePrivate() : m_flags(KFilterBase::WithHeaders) - , m_dev(0L) + , m_dev(nullptr) , m_bAutoDel(false) {} KFilterBase::FilterFlags m_flags; diff -Nru karchive-5.30.0/src/kfilterdev.cpp karchive-5.31.0/src/kfilterdev.cpp --- karchive-5.30.0/src/kfilterdev.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kfilterdev.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "kfilterdev.h" +#include "loggingcategory.h" #include #include @@ -40,7 +41,7 @@ else { // not a warning, since this is called often with other mimetypes (see #88574)... // maybe we can avoid that though? - //qDebug() << "findCompressionByFileName : no compression found for " << fileName; + //qCDebug(KArchiveLog) << "findCompressionByFileName : no compression found for " << fileName; } return KCompressionDevice::None; @@ -94,6 +95,6 @@ // not a warning, since this is called often with other mimetypes (see #88574)... // maybe we can avoid that though? - //qDebug() << "no compression found for" << mimeType; + //qCDebug(KArchiveLog) << "no compression found for" << mimeType; return KCompressionDevice::None; } diff -Nru karchive-5.30.0/src/kfilterdev.h karchive-5.31.0/src/kfilterdev.h --- karchive-5.30.0/src/kfilterdev.h 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kfilterdev.h 2017-02-05 00:49:42.000000000 +0000 @@ -104,7 +104,7 @@ } if (device->compressionType() == KCompressionDevice::None && forceFilter) { delete device; - return 0; + return nullptr; } else { return device; } @@ -141,8 +141,8 @@ KARCHIVE_DEPRECATED static KCompressionDevice *device(QIODevice *inDevice, const QString &mimetype, bool autoDeleteInDevice = true) { - if (inDevice == 0) { - return 0; + if (inDevice == nullptr) { + return nullptr; } CompressionType type = compressionTypeForMimeType(mimetype); KCompressionDevice *device = new KCompressionDevice(inDevice, autoDeleteInDevice, type); diff -Nru karchive-5.30.0/src/kgzipfilter.cpp karchive-5.31.0/src/kgzipfilter.cpp --- karchive-5.30.0/src/kgzipfilter.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kgzipfilter.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -18,6 +18,7 @@ */ #include "kgzipfilter.h" +#include "loggingcategory.h" #include @@ -41,9 +42,9 @@ , crc(0) , isInitialized(false) { - zStream.zalloc = static_cast(0); - zStream.zfree = static_cast(0); - zStream.opaque = static_cast(0); + zStream.zalloc = static_cast(nullptr); + zStream.zfree = static_cast(nullptr); + zStream.opaque = static_cast(nullptr); } z_stream zStream; @@ -93,17 +94,17 @@ : MAX_WBITS /*zlib header*/; const int result = inflateInit2(&d->zStream, windowBits); if (result != Z_OK) { - //qDebug() << "inflateInit2 returned " << result; + //qCDebug(KArchiveLog) << "inflateInit2 returned " << result; return false; } } else if (mode == QIODevice::WriteOnly) { int result = deflateInit2(&d->zStream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); // same here if (result != Z_OK) { - //qDebug() << "deflateInit returned " << result; + //qCDebug(KArchiveLog) << "deflateInit returned " << result; return false; } } else { - //qWarning() << "KGzipFilter: Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; + //qCWarning(KArchiveLog) << "KGzipFilter: Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; return false; } d->mode = mode; @@ -124,13 +125,13 @@ if (d->mode == QIODevice::ReadOnly) { int result = inflateEnd(&d->zStream); if (result != Z_OK) { - //qDebug() << "inflateEnd returned " << result; + //qCDebug(KArchiveLog) << "inflateEnd returned " << result; return false; } } else if (d->mode == QIODevice::WriteOnly) { int result = deflateEnd(&d->zStream); if (result != Z_OK) { - //qDebug() << "deflateEnd returned " << result; + //qCDebug(KArchiveLog) << "deflateEnd returned " << result; return false; } } @@ -143,13 +144,13 @@ if (d->mode == QIODevice::ReadOnly) { int result = inflateReset(&d->zStream); if (result != Z_OK) { - //qDebug() << "inflateReset returned " << result; + //qCDebug(KArchiveLog) << "inflateReset returned " << result; // TODO return false } } else if (d->mode == QIODevice::WriteOnly) { int result = deflateReset(&d->zStream); if (result != Z_OK) { - //qDebug() << "deflateReset returned " << result; + //qCDebug(KArchiveLog) << "deflateReset returned " << result; // TODO return false } d->headerWritten = false; @@ -163,7 +164,7 @@ // We just use this method to check if the data is actually compressed. #ifdef DEBUG_GZIP - qDebug() << "avail=" << d->zStream.avail_in; + qCDebug(KArchiveLog) << "avail=" << d->zStream.avail_in; #endif // Assume not compressed until we see a gzip header d->compressed = false; @@ -173,13 +174,13 @@ return false; // Need at least 10 bytes } #ifdef DEBUG_GZIP - qDebug() << "first byte is " << QString::number(*p, 16); + qCDebug(KArchiveLog) << "first byte is " << QString::number(*p, 16); #endif if (*p++ != 0x1f) { return false; // GZip magic } #ifdef DEBUG_GZIP - qDebug() << "second byte is " << QString::number(*p, 16); + qCDebug(KArchiveLog) << "second byte is " << QString::number(*p, 16); #endif if (*p++ != 0x8b) { return false; @@ -187,7 +188,7 @@ d->compressed = true; #ifdef DEBUG_GZIP - qDebug() << "header OK"; + qCDebug(KArchiveLog) << "header OK"; #endif return true; } @@ -210,7 +211,7 @@ *p++ = 0x8b; *p++ = Z_DEFLATED; *p++ = ORIG_NAME; - put_long(time(0L)); // Modification time (in unix format) + put_long(time(nullptr)); // Modification time (in unix format) *p++ = 0; // Extra flags (2=max compress, 4=fastest compress) *p++ = 3; // Unix @@ -235,9 +236,9 @@ Q_ASSERT(!d->footerWritten); Bytef *p = d->zStream.next_out; int i = d->zStream.avail_out; - //qDebug() << "avail_out=" << i << "writing CRC=" << QString::number(d->crc, 16) << "at p=" << p; + //qCDebug(KArchiveLog) << "avail_out=" << i << "writing CRC=" << QString::number(d->crc, 16) << "at p=" << p; put_long(d->crc); - //qDebug() << "writing totalin=" << d->zStream.total_in << "at p=" << p; + //qCDebug(KArchiveLog) << "writing totalin=" << d->zStream.total_in << "at p=" << p; put_long(d->zStream.total_in); i -= p - d->zStream.next_out; d->zStream.next_out = p; @@ -253,7 +254,7 @@ void KGzipFilter::setInBuffer(const char *data, uint size) { #ifdef DEBUG_GZIP - qDebug() << "avail_in=" << size; + qCDebug(KArchiveLog) << "avail_in=" << size; #endif d->zStream.avail_in = size; d->zStream.next_in = reinterpret_cast(const_cast(data)); @@ -288,10 +289,10 @@ { #ifndef NDEBUG if (d->mode == 0) { - //qWarning() << "mode==0; KGzipFilter::init was not called!"; + //qCWarning(KArchiveLog) << "mode==0; KGzipFilter::init was not called!"; return KFilterBase::Error; } else if (d->mode == QIODevice::WriteOnly) { - //qWarning() << "uncompress called but the filter was opened for writing!"; + //qCWarning(KArchiveLog) << "uncompress called but the filter was opened for writing!"; return KFilterBase::Error; } Q_ASSERT(d->mode == QIODevice::ReadOnly); @@ -302,17 +303,17 @@ } #ifdef DEBUG_GZIP - qDebug() << "Calling inflate with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); - qDebug() << " next_in=" << d->zStream.next_in; + qCDebug(KArchiveLog) << "Calling inflate with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + qCDebug(KArchiveLog) << " next_in=" << d->zStream.next_in; #endif while (d->zStream.avail_in > 0) { int result = inflate(&d->zStream, Z_SYNC_FLUSH); #ifdef DEBUG_GZIP - qDebug() << " -> inflate returned " << result; - qDebug() << " now avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); - qDebug() << " next_in=" << d->zStream.next_in; + qCDebug(KArchiveLog) << " -> inflate returned " << result; + qCDebug(KArchiveLog) << " now avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + qCDebug(KArchiveLog) << " next_in=" << d->zStream.next_in; #endif if (result == Z_OK) { @@ -354,25 +355,25 @@ const Bytef *p = d->zStream.next_in; ulong len = d->zStream.avail_in; #ifdef DEBUG_GZIP - qDebug() << " calling deflate with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + qCDebug(KArchiveLog) << " calling deflate with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); #endif const int result = deflate(&d->zStream, finish ? Z_FINISH : Z_NO_FLUSH); if (result != Z_OK && result != Z_STREAM_END) { - //qDebug() << " deflate returned " << result; + //qCDebug(KArchiveLog) << " deflate returned " << result; } if (d->headerWritten) { - //qDebug() << "Computing CRC for the next " << len - d->zStream.avail_in << " bytes"; + //qCDebug(KArchiveLog) << "Computing CRC for the next " << len - d->zStream.avail_in << " bytes"; d->crc = crc32(d->crc, p, len - d->zStream.avail_in); } KGzipFilter::Result callerResult = result == Z_OK ? KFilterBase::Ok : (Z_STREAM_END ? KFilterBase::End : KFilterBase::Error); if (result == Z_STREAM_END && d->headerWritten && !d->footerWritten) { if (d->zStream.avail_out >= 8 /*footer size*/) { - //qDebug() << "finished, write footer"; + //qCDebug(KArchiveLog) << "finished, write footer"; writeFooter(); } else { // No room to write the footer (#157706/#188415), we'll have to do it on the next pass. - //qDebug() << "finished, but no room for footer yet"; + //qCDebug(KArchiveLog) << "finished, but no room for footer yet"; callerResult = KFilterBase::Ok; } } diff -Nru karchive-5.30.0/src/klimitediodevice.cpp karchive-5.31.0/src/klimitediodevice.cpp --- karchive-5.30.0/src/klimitediodevice.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/klimitediodevice.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -17,19 +17,20 @@ */ #include "klimitediodevice_p.h" +#include "loggingcategory.h" KLimitedIODevice::KLimitedIODevice(QIODevice *dev, qint64 start, qint64 length) : m_dev(dev) , m_start(start) , m_length(length) { - //qDebug() << "start=" << start << "length=" << length; + //qCDebug(KArchiveLog) << "start=" << start << "length=" << length; open(QIODevice::ReadOnly); //krazy:exclude=syscalls } bool KLimitedIODevice::open(QIODevice::OpenMode m) { - //qDebug() << "m=" << m; + //qCDebug(KArchiveLog) << "m=" << m; if (m & QIODevice::ReadOnly) { /*bool ok = false; if ( m_dev->isOpen() ) @@ -39,7 +40,7 @@ if ( ok )*/ m_dev->seek(m_start); // No concurrent access ! } else { - //qWarning() << "KLimitedIODevice::open only supports QIODevice::ReadOnly!"; + //qCWarning(KArchiveLog) << "KLimitedIODevice::open only supports QIODevice::ReadOnly!"; } setOpenMode(QIODevice::ReadOnly); return true; diff -Nru karchive-5.30.0/src/knonefilter.cpp karchive-5.31.0/src/knonefilter.cpp --- karchive-5.30.0/src/knonefilter.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/knonefilter.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -31,8 +31,8 @@ : mode(0) , avail_out(0) , avail_in(0) - , next_in(NULL) - , next_out(NULL) + , next_in(nullptr) + , next_out(nullptr) { } diff -Nru karchive-5.30.0/src/krcc.cpp karchive-5.31.0/src/krcc.cpp --- karchive-5.30.0/src/krcc.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/krcc.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -20,6 +20,7 @@ #include "krcc.h" #include "karchive_p.h" +#include "loggingcategory.h" #include #include @@ -59,7 +60,7 @@ if (f.open(QIODevice::ReadOnly)) { return f.readAll(); } - qWarning() << "Couldn't open" << m_resourcePath; + qCWarning(KArchiveLog) << "Couldn't open" << m_resourcePath; return QByteArray(); } QIODevice *createDevice() const Q_DECL_OVERRIDE @@ -88,14 +89,14 @@ qint64, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to RCC file")); - qWarning() << "doPrepareWriting not implemented for KRcc"; + qCWarning(KArchiveLog) << "doPrepareWriting not implemented for KRcc"; return false; } bool KRcc::doFinishWriting(qint64) { setErrorString(tr("Cannot write to RCC file")); - qWarning() << "doFinishWriting not implemented for KRcc"; + qCWarning(KArchiveLog) << "doFinishWriting not implemented for KRcc"; return false; } @@ -103,7 +104,7 @@ mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to RCC file")); - qWarning() << "doWriteDir not implemented for KRcc"; + qCWarning(KArchiveLog) << "doWriteDir not implemented for KRcc"; return false; } @@ -111,7 +112,7 @@ const QString &, mode_t, const QDateTime &, const QDateTime &, const QDateTime &) { setErrorString(tr("Cannot write to RCC file")); - qWarning() << "doWriteSymLink not implemented for KRcc"; + qCWarning(KArchiveLog) << "doWriteSymLink not implemented for KRcc"; return false; } diff -Nru karchive-5.30.0/src/ktar.cpp karchive-5.31.0/src/ktar.cpp --- karchive-5.30.0/src/ktar.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/ktar.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -19,6 +19,7 @@ #include "ktar.h" #include "karchive_p.h" +#include "loggingcategory.h" #include // strtol #include @@ -48,8 +49,8 @@ KTarPrivate(KTar *parent) : q(parent) , tarEnd(0) - , tmpFile(0) - , compressionDevice(Q_NULLPTR) + , tmpFile(nullptr) + , compressionDevice(nullptr) { } @@ -108,7 +109,7 @@ mime = db.mimeTypeForFile(fileName(), QMimeDatabase::MatchExtension); } - //qDebug() << mode << mime->name(); + //qCDebug(KArchiveLog) << mode << mime->name(); if (mime.inherits(QStringLiteral("application/x-compressed-tar")) || mime.inherits(QString::fromLatin1(application_gzip))) { // gzipped tar file (with possibly invalid file name), ask for gzip filter @@ -133,7 +134,7 @@ } if (!d->mimetype.isEmpty()) { // Create a compression filter on top of the QSaveFile device that KArchive created. - //qDebug() << "creating KFilterDev for" << d->mimetype; + //qCDebug(KArchiveLog) << "creating KFilterDev for" << d->mimetype; KCompressionDevice::CompressionType type = KFilterDev::compressionTypeForMimeType(d->mimetype); d->compressionDevice = new KCompressionDevice(device(), false, type); setDevice(d->compressionDevice); @@ -154,7 +155,7 @@ d->tmpFile = new QTemporaryFile(); d->tmpFile->setFileTemplate(QDir::tempPath() + QStringLiteral("/") + QLatin1String("ktar-XXXXXX.tar")); d->tmpFile->open(); - //qDebug() << "creating tempfile:" << d->tmpFile->fileName(); + //qCDebug(KArchiveLog) << "creating tempfile:" << d->tmpFile->fileName(); setDevice(d->tmpFile); return true; @@ -176,7 +177,7 @@ void KTar::setOrigFileName(const QByteArray &fileName) { if (!isOpen() || !(mode() & QIODevice::WriteOnly)) { - //qWarning() << "KTar::setOrigFileName: File must be opened for writing first.\n"; + //qCWarning(KArchiveLog) << "KTar::setOrigFileName: File must be opened for writing first.\n"; return; } d->origFileName = fileName; @@ -212,7 +213,7 @@ if (strncmp(buffer + 148 + 6 - s.length(), s.data(), s.length()) && strncmp(buffer + 148 + 7 - s.length(), s.data(), s.length()) && strncmp(buffer + 148 + 8 - s.length(), s.data(), s.length())) { - /*qWarning() << "KTar: invalid TAR file. Header is:" << QByteArray( buffer+257, 5 ) + /*qCWarning(KArchiveLog) << "KTar: invalid TAR file. Header is:" << QByteArray( buffer+257, 5 ) << "instead of ustar. Reading from wrong pos in file?" << "checksum=" << QByteArray( buffer + 148 + 6 - s.length(), s.length() );*/ return -1; @@ -230,11 +231,11 @@ bool KTar::KTarPrivate::readLonglink(char *buffer, QByteArray &longlink) { qint64 n = 0; - //qDebug() << "reading longlink from pos " << q->device()->pos(); + //qCDebug(KArchiveLog) << "reading longlink from pos " << q->device()->pos(); QIODevice *dev = q->device(); // read size of longlink from size field in header // size is in bytes including the trailing null (which we ignore) - qint64 size = QByteArray(buffer + 0x7c, 12).trimmed().toLongLong(0, 8 /*octal*/); + qint64 size = QByteArray(buffer + 0x7c, 12).trimmed().toLongLong(nullptr, 8 /*octal*/); size--; // ignore trailing null longlink.resize(size); @@ -313,7 +314,7 @@ return true; } - //qDebug() << "filling tmpFile of mimetype" << mimetype; + //qCDebug(KArchiveLog) << "filling tmpFile of mimetype" << mimetype; KCompressionDevice::CompressionType compressionType = KFilterDev::compressionTypeForMimeType(mimetype); KCompressionDevice filterDev(fileName, compressionType); @@ -349,7 +350,7 @@ Q_ASSERT(file->isOpen()); Q_ASSERT(file->openMode() & QIODevice::ReadOnly); - //qDebug() << "filling tmpFile finished."; + //qCDebug(KArchiveLog) << "filling tmpFile finished."; return true; } @@ -374,7 +375,7 @@ if (!dev) { setErrorString(tr("Could not get underlying device")); - qWarning() << "Could not get underlying device"; + qCWarning(KArchiveLog) << "Could not get underlying device"; return false; } @@ -447,7 +448,7 @@ isdir = false; isDumpDir = true; } - //qDebug() << nm << "isdir=" << isdir << "pos=" << dev->pos() << "typeflag=" << typeflag << " islink=" << ( typeflag == '1' || typeflag == '2' ); + //qCDebug(KArchiveLog) << nm << "isdir=" << isdir << "pos=" << dev->pos() << "typeflag=" << typeflag << " islink=" << ( typeflag == '1' || typeflag == '2' ); if (typeflag == 'x' || typeflag == 'g') { // pax extended header, or pax global extended header // Skip it for now. TODO: implement reading of extended header, as per http://pubs.opengroup.org/onlinepubs/009695399/utilities/pax.html @@ -461,27 +462,27 @@ KArchiveEntry *e; if (isdir) { - //qDebug() << "directory" << nm; + //qCDebug(KArchiveLog) << "directory" << nm; e = new KArchiveDirectory(this, nm, access, KArchivePrivate::time_tToDateTime(time), user, group, symlink); } else { // read size QByteArray sizeBuffer(buffer + 0x7c, 12); - qint64 size = sizeBuffer.trimmed().toLongLong(0, 8 /*octal*/); - //qDebug() << "sizeBuffer='" << sizeBuffer << "' -> size=" << size; + qint64 size = sizeBuffer.trimmed().toLongLong(nullptr, 8 /*octal*/); + //qCDebug(KArchiveLog) << "sizeBuffer='" << sizeBuffer << "' -> size=" << size; // for isDumpDir we will skip the additional info about that dirs contents if (isDumpDir) { - //qDebug() << nm << "isDumpDir"; + //qCDebug(KArchiveLog) << nm << "isDumpDir"; e = new KArchiveDirectory(this, nm, access, KArchivePrivate::time_tToDateTime(time), user, group, symlink); } else { // Let's hack around hard links. Our classes don't support that, so make them symlinks if (typeflag == '1') { - //qDebug() << "Hard link, setting size to 0 instead of" << size; + //qCDebug(KArchiveLog) << "Hard link, setting size to 0 instead of" << size; size = 0; // no contents } - //qDebug() << "file" << nm << "size=" << size; + //qCDebug(KArchiveLog) << "file" << nm << "size=" << size; e = new KArchiveFile(this, nm, access, KArchivePrivate::time_tToDateTime(time), user, group, symlink, dev->pos(), size); } @@ -489,9 +490,9 @@ // Skip contents + align bytes qint64 rest = size % 0x200; qint64 skip = size + (rest ? 0x200 - rest : 0); - //qDebug() << "pos()=" << dev->pos() << "rest=" << rest << "skipping" << skip; + //qCDebug(KArchiveLog) << "pos()=" << dev->pos() << "rest=" << rest << "skipping" << skip; if (! dev->seek(dev->pos() + skip)) { - //qWarning() << "skipping" << skip << "failed"; + //qCWarning(KArchiveLog) << "skipping" << skip << "failed"; } } @@ -512,7 +513,7 @@ d->addEntry(e); } } else { - //qDebug("Terminating. Read %d bytes, first one is %d", n, buffer[0]); + //qCDebug(KArchiveLog) << "Terminating. Read " << n << " bytes, first one is " << buffer[0]; d->tarEnd = dev->pos() - n; // Remember end of archive ende = true; } @@ -531,7 +532,7 @@ return true; } - //qDebug() << "Write temporary file to compressed file" << fileName << mimetype; + //qCDebug(KArchiveLog) << "Write temporary file to compressed file" << fileName << mimetype; bool forced = false; if (QLatin1String(application_gzip) == mimetype || QLatin1String(application_bzip) == mimetype || @@ -564,7 +565,7 @@ file->close(); dev.close(); - //qDebug() << "Write temporary file to compressed file done."; + //qCDebug(KArchiveLog) << "Write temporary file to compressed file done."; return true; } @@ -580,8 +581,8 @@ if (d->tmpFile && (mode() & QIODevice::WriteOnly)) { ok = d->writeBackTempFile(fileName()); delete d->tmpFile; - d->tmpFile = 0; - setDevice(0); + d->tmpFile = nullptr; + setDevice(nullptr); } return ok; @@ -727,13 +728,13 @@ { if (!isOpen()) { setErrorString(tr("Application error: TAR file must be open before being written into")); - qWarning() << "doPrepareWriting failed: !isOpen()"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { setErrorString(tr("Application error: attempted to write into non-writable 7-Zip file")); - qWarning() << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; return false; } @@ -802,13 +803,13 @@ { if (!isOpen()) { setErrorString(tr("Application error: TAR file must be open before being written into")); - qWarning() << "doWriteDir failed: !isOpen()"; + qCWarning(KArchiveLog) << "doWriteDir failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { setErrorString(tr("Application error: attempted to write into non-writable TAR file")); - qWarning() << "doWriteDir failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doWriteDir failed: !(mode() & QIODevice::WriteOnly)"; return false; } @@ -866,13 +867,13 @@ { if (!isOpen()) { setErrorString(tr("Application error: TAR file must be open before being written into")); - qWarning() << "doWriteSymLink failed: !isOpen()"; + qCWarning(KArchiveLog) << "doWriteSymLink failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { setErrorString(tr("Application error: attempted to write into non-writable TAR file")); - qWarning() << "doWriteSymLink failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doWriteSymLink failed: !(mode() & QIODevice::WriteOnly)"; return false; } diff -Nru karchive-5.30.0/src/kxzfilter.cpp karchive-5.31.0/src/kxzfilter.cpp --- karchive-5.30.0/src/kxzfilter.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kxzfilter.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -21,6 +21,7 @@ */ #include "kxzfilter.h" +#include "loggingcategory.h" #include @@ -75,7 +76,7 @@ d->flag = flag; lzma_ret result; - d->zStream.next_in = 0; + d->zStream.next_in = nullptr; d->zStream.avail_in = 0; if (mode == QIODevice::ReadOnly) { switch (flag) { @@ -85,15 +86,15 @@ */ result = lzma_auto_decoder(&d->zStream, 100 << 20, 0); if (result != LZMA_OK) { - qWarning() << "lzma_auto_decoder returned" << result; + qCWarning(KArchiveLog) << "lzma_auto_decoder returned" << result; return false; } break; case LZMA: { d->filters[0].id = LZMA_FILTER_LZMA1; - d->filters[0].options = NULL; + d->filters[0].options = nullptr; d->filters[1].id = LZMA_VLI_UNKNOWN; - d->filters[1].options = NULL; + d->filters[1].options = nullptr; Q_ASSERT(properties.size() == 5); unsigned char props[5]; @@ -101,46 +102,46 @@ props[i] = properties[i]; } - result = lzma_properties_decode(&d->filters[0], NULL, props, sizeof (props)); + result = lzma_properties_decode(&d->filters[0], nullptr, props, sizeof (props)); if (result != LZMA_OK) { - qWarning() << "lzma_properties_decode returned" << result; + qCWarning(KArchiveLog) << "lzma_properties_decode returned" << result; return false; } break; } case LZMA2: { d->filters[0].id = LZMA_FILTER_LZMA2; - d->filters[0].options = NULL; + d->filters[0].options = nullptr; d->filters[1].id = LZMA_VLI_UNKNOWN; - d->filters[1].options = NULL; + d->filters[1].options = nullptr; Q_ASSERT(properties.size() == 1); unsigned char props[1]; props[0] = properties[0]; - result = lzma_properties_decode(&d->filters[0], NULL, props, sizeof (props)); + result = lzma_properties_decode(&d->filters[0], nullptr, props, sizeof (props)); if (result != LZMA_OK) { - qWarning() << "lzma_properties_decode returned" << result; + qCWarning(KArchiveLog) << "lzma_properties_decode returned" << result; return false; } break; } case BCJ: { d->filters[0].id = LZMA_FILTER_X86; - d->filters[0].options = NULL; + d->filters[0].options = nullptr; unsigned char props[5] = { 0x5d, 0x00, 0x00, 0x08, 0x00 } ; d->filters[1].id = LZMA_FILTER_LZMA1; - d->filters[1].options = NULL; - result = lzma_properties_decode(&d->filters[1], NULL, props, sizeof (props)); + d->filters[1].options = nullptr; + result = lzma_properties_decode(&d->filters[1], nullptr, props, sizeof (props)); if (result != LZMA_OK) { - qWarning() << "lzma_properties_decode1 returned" << result; + qCWarning(KArchiveLog) << "lzma_properties_decode1 returned" << result; return false; } d->filters[2].id = LZMA_VLI_UNKNOWN; - d->filters[2].options = NULL; + d->filters[2].options = nullptr; break; } @@ -149,14 +150,14 @@ case ARM: case ARMTHUMB: case SPARC: - //qDebug() << "flag" << flag << "props size" << properties.size(); + //qCDebug(KArchiveLog) << "flag" << flag << "props size" << properties.size(); break; } if (flag != AUTO) { result = lzma_raw_decoder(&d->zStream, d->filters); if (result != LZMA_OK) { - qWarning() << "lzma_raw_decoder returned" << result; + qCWarning(KArchiveLog) << "lzma_raw_decoder returned" << result; return false; } } @@ -172,16 +173,16 @@ d->filters[0].id = LZMA_FILTER_LZMA2; d->filters[0].options = &lzma_opt; d->filters[1].id = LZMA_VLI_UNKNOWN; - d->filters[1].options = NULL; + d->filters[1].options = nullptr; } result = lzma_raw_encoder(&d->zStream, d->filters); } if (result != LZMA_OK) { - qWarning() << "lzma_easy_encoder returned" << result; + qCWarning(KArchiveLog) << "lzma_easy_encoder returned" << result; return false; } } else { - //qWarning() << "Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; + //qCWarning(KArchiveLog) << "Unsupported mode " << mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; return false; } d->mode = mode; @@ -199,7 +200,7 @@ if (d->mode == QIODevice::ReadOnly || d->mode == QIODevice::WriteOnly) { lzma_end(&d->zStream); } else { - //qWarning() << "Unsupported mode " << d->mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; + //qCWarning(KArchiveLog) << "Unsupported mode " << d->mode << ". Only QIODevice::ReadOnly and QIODevice::WriteOnly supported"; return false; } d->isInitialized = false; @@ -208,7 +209,7 @@ void KXzFilter::reset() { - //qDebug() << "KXzFilter::reset"; + //qCDebug(KArchiveLog) << "KXzFilter::reset"; // liblzma doesn't have a reset call... terminate(); init(d->mode); @@ -238,13 +239,13 @@ KXzFilter::Result KXzFilter::uncompress() { - //qDebug() << "Calling lzma_code with avail_in=" << inBufferAvailable() << " avail_out =" << outBufferAvailable(); + //qCDebug(KArchiveLog) << "Calling lzma_code with avail_in=" << inBufferAvailable() << " avail_out =" << outBufferAvailable(); lzma_ret result; result = lzma_code(&d->zStream, LZMA_RUN); /*if (result != LZMA_OK) { - qDebug() << "lzma_code returned " << result; - //qDebug() << "KXzFilter::uncompress " << ( result == LZMA_STREAM_END ? KFilterBase::End : KFilterBase::Error ); + qCDebug(KArchiveLog) << "lzma_code returned " << result; + //qCDebug(KArchiveLog) << "KXzFilter::uncompress " << ( result == LZMA_STREAM_END ? KFilterBase::End : KFilterBase::Error ); }*/ switch (result) { @@ -259,18 +260,18 @@ KXzFilter::Result KXzFilter::compress(bool finish) { - //qDebug() << "Calling lzma_code with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); + //qCDebug(KArchiveLog) << "Calling lzma_code with avail_in=" << inBufferAvailable() << " avail_out=" << outBufferAvailable(); lzma_ret result = lzma_code(&d->zStream, finish ? LZMA_FINISH : LZMA_RUN); switch (result) { case LZMA_OK: return KFilterBase::Ok; break; case LZMA_STREAM_END: - //qDebug() << " lzma_code returned " << result; + //qCDebug(KArchiveLog) << " lzma_code returned " << result; return KFilterBase::End; break; default: - //qDebug() << " lzma_code returned " << result; + //qCDebug(KArchiveLog) << " lzma_code returned " << result; return KFilterBase::Error; break; } diff -Nru karchive-5.30.0/src/kzip.cpp karchive-5.31.0/src/kzip.cpp --- karchive-5.30.0/src/kzip.cpp 2017-01-08 15:15:58.000000000 +0000 +++ karchive-5.31.0/src/kzip.cpp 2017-02-05 00:49:42.000000000 +0000 @@ -21,6 +21,7 @@ #include "karchive_p.h" #include "kfilterdev.h" #include "klimitediodevice_p.h" +#include "loggingcategory.h" #include #include @@ -109,7 +110,7 @@ , exttimestamp_seen(false) , newinfounix_seen(false) { - ctime = mtime = atime = time(0); + ctime = mtime = atime = time(nullptr); } }; @@ -125,7 +126,7 @@ ParseFileInfo &pfi) { if (size < 1) { - //qDebug() << "premature end of extended timestamp (#1)"; + //qCDebug(KArchiveLog) << "premature end of extended timestamp (#1)"; return false; }/*end if*/ int flags = *buffer; // read flags @@ -134,7 +135,7 @@ if (flags & 1) { // contains modification time if (size < 4) { - //qDebug() << "premature end of extended timestamp (#2)"; + //qCDebug(KArchiveLog) << "premature end of extended timestamp (#2)"; return false; }/*end if*/ pfi.mtime = uint((uchar)buffer[0] | (uchar)buffer[1] << 8 @@ -151,7 +152,7 @@ if (flags & 2) { // contains last access time if (size < 4) { - //qDebug() << "premature end of extended timestamp (#3)"; + //qCDebug(KArchiveLog) << "premature end of extended timestamp (#3)"; return true; }/*end if*/ pfi.atime = uint((uchar)buffer[0] | (uchar)buffer[1] << 8 @@ -162,7 +163,7 @@ if (flags & 4) { // contains creation time if (size < 4) { - //qDebug() << "premature end of extended timestamp (#4)"; + //qCDebug(KArchiveLog) << "premature end of extended timestamp (#4)"; return true; }/*end if*/ pfi.ctime = uint((uchar)buffer[0] | (uchar)buffer[1] << 8 @@ -191,7 +192,7 @@ } if (size < 8) { - //qDebug() << "premature end of Info-ZIP unix extra field old"; + //qCDebug(KArchiveLog) << "premature end of Info-ZIP unix extra field old"; return false; } @@ -228,7 +229,7 @@ } if (size < 4) { - qDebug() << "premature end of Info-ZIP unix extra field new"; + qCDebug(KArchiveLog) << "premature end of Info-ZIP unix extra field new"; return false; } @@ -267,8 +268,8 @@ size -= 4; if (fieldsize > size) { - //qDebug() << "fieldsize: " << fieldsize << " size: " << size; - //qDebug() << "premature end of extra fields reached"; + //qCDebug(KArchiveLog) << "fieldsize: " << fieldsize << " size: " << size; + //qCDebug(KArchiveLog) << "premature end of extra fields reached"; break; } @@ -354,7 +355,7 @@ while (!headerTokenFound) { int n = dev->read(buffer, 1); if (n < 1) { - //qWarning() << "Invalid ZIP file. Unexpected end of file. (#2)"; + //qCWarning(KArchiveLog) << "Invalid ZIP file. Unexpected end of file. (#2)"; return false; } @@ -364,7 +365,7 @@ n = dev->read(buffer, 3); if (n < 3) { - //qWarning() << "Invalid ZIP file. Unexpected end of file. (#3)"; + //qCWarning(KArchiveLog) << "Invalid ZIP file. Unexpected end of file. (#3)"; return false; } @@ -392,8 +393,8 @@ public: KZipPrivate() : m_crc(0) - , m_currentFile(0) - , m_currentDev(0) + , m_currentFile(nullptr) + , m_currentDev(nullptr) , m_compression(8) , m_extraField(KZip::NoExtraField) , m_offset(0) @@ -427,7 +428,7 @@ KZip::~KZip() { - //qDebug() << this; + //qCDebug(KArchiveLog) << this; if (isOpen()) { close(); } @@ -436,7 +437,7 @@ bool KZip::openArchive(QIODevice::OpenMode mode) { - //qDebug(); + //qCDebug(KArchiveLog); d->m_fileList.clear(); if (mode == QIODevice::WriteOnly) { @@ -460,8 +461,8 @@ bool startOfFile = true; for (;;) { // repeat until 'end of entries' signature is reached - //qDebug() << "loop starts"; - //qDebug() << "dev->pos() now : " << dev->pos(); + //qCDebug(KArchiveLog) << "loop starts"; + //qCDebug(KArchiveLog) << "dev->pos() now : " << dev->pos(); n = dev->read(buffer, 4); if (n < 4) { @@ -470,13 +471,13 @@ } if (!memcmp(buffer, "PK\5\6", 4)) { // 'end of entries' - //qDebug() << "PK56 found end of archive"; + //qCDebug(KArchiveLog) << "PK56 found end of archive"; startOfFile = false; break; } if (!memcmp(buffer, "PK\3\4", 4)) { // local file header - //qDebug() << "PK34 found local file header"; + //qCDebug(KArchiveLog) << "PK34 found local file header"; startOfFile = false; // can this fail ??? dev->seek(dev->pos() + 2); // skip 'version needed to extract' @@ -500,12 +501,12 @@ const int extralen = uint(uchar(buffer[22])) | uint(uchar(buffer[23])) << 8; /* - qDebug() << "general purpose bit flag: " << gpf; - qDebug() << "compressed size: " << compr_size; - qDebug() << "uncompressed size: " << uncomp_size; - qDebug() << "namelen: " << namelen; - qDebug() << "extralen: " << extralen; - qDebug() << "archive size: " << dev->size(); + qCDebug(KArchiveLog) << "general purpose bit flag: " << gpf; + qCDebug(KArchiveLog) << "compressed size: " << compr_size; + qCDebug(KArchiveLog) << "uncompressed size: " << uncomp_size; + qCDebug(KArchiveLog) << "namelen: " << namelen; + qCDebug(KArchiveLog) << "extralen: " << extralen; + qCDebug(KArchiveLog) << "archive size: " << dev->size(); */ // read fileName @@ -526,7 +527,7 @@ int handledextralen = qMin(extralen, (int)sizeof buffer); //if (handledextralen) - // qDebug() << "handledextralen: " << handledextralen; + // qCDebug(KArchiveLog) << "handledextralen: " << handledextralen; n = dev->read(buffer, handledextralen); // no error msg necessary as we deliberately truncate the extra field @@ -550,7 +551,7 @@ } } else { // here we skip the compressed data and jump to the next header - //qDebug() << "general purpose bit flag indicates, that local file header contains valid size"; + //qCDebug(KArchiveLog) << "general purpose bit flag indicates, that local file header contains valid size"; bool foundSignature = false; // check if this could be a symbolic link if (compression_mode == NoCompression @@ -573,21 +574,21 @@ } foundSignature = true; } else { -// qDebug() << "before interesting dev->pos(): " << dev->pos(); +// qCDebug(KArchiveLog) << "before interesting dev->pos(): " << dev->pos(); bool success = dev->seek(dev->pos() + compr_size); // can this fail ??? Q_UNUSED(success); // prevent warning in release builds. Q_ASSERT(success); // let's see... - /* qDebug() << "after interesting dev->pos(): " << dev->pos(); + /* qCDebug(KArchiveLog) << "after interesting dev->pos(): " << dev->pos(); if (success) - qDebug() << "dev->at was successful... "; + qCDebug(KArchiveLog) << "dev->at was successful... "; else - qDebug() << "dev->at failed... ";*/ + qCDebug(KArchiveLog) << "dev->at failed... ";*/ } } // test for optional data descriptor if (!foundSignature) { -// qDebug() << "Testing for optional data descriptor"; +// qCDebug(KArchiveLog) << "Testing for optional data descriptor"; // read static data descriptor n = dev->read(buffer, 4); if (n < 4) { @@ -609,7 +610,7 @@ } pfi_map.insert(fileName, pfi); } else if (!memcmp(buffer, "PK\1\2", 4)) { // central block - //qDebug() << "PK12 found central block"; + //qCDebug(KArchiveLog) << "PK12 found central block"; startOfFile = false; // so we reached the central header at the end of the zip file @@ -631,20 +632,20 @@ } //int gpf = (uchar)buffer[9] << 8 | (uchar)buffer[10]; - //qDebug() << "general purpose flag=" << gpf; + //qCDebug(KArchiveLog) << "general purpose flag=" << gpf; // length of the fileName (well, pathname indeed) int namelen = (uchar)buffer[29] << 8 | (uchar)buffer[28]; Q_ASSERT(namelen > 0); QByteArray bufferName = dev->read(namelen); if (bufferName.size() < namelen) { - //qWarning() << "Invalid ZIP file. Name not completely read"; + //qCWarning(KArchiveLog) << "Invalid ZIP file. Name not completely read"; } ParseFileInfo pfi = pfi_map.value(bufferName, ParseFileInfo()); QString name(QFile::decodeName(bufferName)); - //qDebug() << "name: " << name; + //qCDebug(KArchiveLog) << "name: " << name; // only in central header ! see below. // length of extra attributes int extralen = (uchar)buffer[31] << 8 | (uchar)buffer[30]; @@ -653,8 +654,8 @@ // compression method of this file int cmethod = (uchar)buffer[11] << 8 | (uchar)buffer[10]; - //qDebug() << "cmethod: " << cmethod; - //qDebug() << "extralen: " << extralen; + //qCDebug(KArchiveLog) << "cmethod: " << cmethod; + //qCDebug(KArchiveLog) << "extralen: " << extralen; // crc32 of the file uint crc32 = (uchar)buffer[19] << 24 | (uchar)buffer[18] << 16 | @@ -678,14 +679,14 @@ int localextralen = pfi.extralen; // FIXME: this will not work if // no local header exists - //qDebug() << "localextralen: " << localextralen; + //qCDebug(KArchiveLog) << "localextralen: " << localextralen; // offset, where the real data for uncompression starts uint dataoffset = localheaderoffset + 30 + localextralen + namelen; //comment only in central header - //qDebug() << "esize: " << esize; - //qDebug() << "eoffset: " << eoffset; - //qDebug() << "csize: " << csize; + //qCDebug(KArchiveLog) << "esize: " << esize; + //qCDebug(KArchiveLog) << "eoffset: " << eoffset; + //qCDebug(KArchiveLog) << "csize: " << csize; int os_madeby = (uchar)buffer[5]; bool isdir = false; @@ -720,12 +721,12 @@ QString path = QDir::cleanPath(name); const KArchiveEntry *ent = rootDir()->entry(path); if (ent && ent->isDirectory()) { - //qDebug() << "Directory already exists, NOT going to add it again"; - entry = 0; + //qCDebug(KArchiveLog) << "Directory already exists, NOT going to add it again"; + entry = nullptr; } else { QDateTime mtime = KArchivePrivate::time_tToDateTime(pfi.mtime); entry = new KArchiveDirectory(this, entryName, access, mtime, rootDir()->user(), rootDir()->group(), QString()); - //qDebug() << "KArchiveDirectory created, entryName= " << entryName << ", name=" << name; + //qCDebug(KArchiveLog) << "KArchiveDirectory created, entryName= " << entryName << ", name=" << name; } } else { QString symlink; @@ -739,7 +740,7 @@ ucsize, cmethod, csize); static_cast(entry)->setHeaderStart(localheaderoffset); static_cast(entry)->setCRC32(crc32); - //qDebug() << "KZipFileEntry created, entryName= " << entryName << ", name=" << name; + //qCDebug(KArchiveLog) << "KZipFileEntry created, entryName= " << entryName << ", name=" << name; d->m_fileList.append(static_cast(entry)); } @@ -766,7 +767,7 @@ } else if (startOfFile) { // The file does not start with any ZIP header (e.g. self-extractable ZIP files) // Therefore we need to find the first PK\003\004 (local header) - //qDebug() << "Try to skip start of file"; + //qCDebug(KArchiveLog) << "Try to skip start of file"; startOfFile = false; bool foundSignature = false; @@ -812,14 +813,14 @@ return false; } } - //qDebug() << "*** done *** "; + //qCDebug(KArchiveLog) << "*** done *** "; return true; } bool KZip::closeArchive() { if (!(mode() & QIODevice::WriteOnly)) { - //qDebug() << "readonly"; + //qCDebug(KArchiveLog) << "readonly"; return true; } @@ -831,7 +832,7 @@ uLong crc = crc32(0L, Z_NULL, 0); qint64 centraldiroffset = device()->pos(); - //qDebug() << "closearchive: centraldiroffset: " << centraldiroffset; + //qCDebug(KArchiveLog) << "closearchive: centraldiroffset: " << centraldiroffset; qint64 atbackup = centraldiroffset; QMutableListIterator it(d->m_fileList); @@ -844,7 +845,7 @@ .arg(device()->errorString())); return false; } - //qDebug() << "closearchive setcrcandcsize: fileName:" + //qCDebug(KArchiveLog) << "closearchive setcrcandcsize: fileName:" // << it.current()->path() // << "encoding:" << it.current()->encoding(); @@ -878,7 +879,7 @@ it.toFront(); while (it.hasNext()) { it.next(); - //qDebug() << "fileName:" << it.current()->path() + //qCDebug(KArchiveLog) << "fileName:" << it.current()->path() // << "encoding:" << it.current()->encoding(); QByteArray path = QFile::encodeName(it.value()->path()); @@ -939,7 +940,7 @@ // file name strncpy(buffer + 46, path.constData(), path.length()); - //qDebug() << "closearchive length to write: " << bufferSize; + //qCDebug(KArchiveLog) << "closearchive length to write: " << bufferSize; // extra field if (d->m_extraField == ModificationTime) { @@ -970,8 +971,8 @@ } } qint64 centraldirendoffset = device()->pos(); - //qDebug() << "closearchive: centraldirendoffset: " << centraldirendoffset; - //qDebug() << "closearchive: device()->pos(): " << device()->pos(); + //qCDebug(KArchiveLog) << "closearchive: centraldirendoffset: " << centraldirendoffset; + //qCDebug(KArchiveLog) << "closearchive: device()->pos(): " << device()->pos(); //write end of central dir record. buffer[0] = 'P'; //end of central dir signature @@ -986,7 +987,7 @@ buffer[7] = 0; int count = d->m_fileList.count(); - //qDebug() << "number of files (count): " << count; + //qCDebug(KArchiveLog) << "number of files (count): " << count; buffer[8] = char(count); // total number of entries in central dir of buffer[9] = char(count >> 8); // this disk @@ -1000,8 +1001,8 @@ buffer[14] = char(cdsize >> 16); buffer[15] = char(cdsize >> 24); - //qDebug() << "end : centraldiroffset: " << centraldiroffset; - //qDebug() << "end : centraldirsize: " << cdsize; + //qCDebug(KArchiveLog) << "end : centraldiroffset: " << centraldiroffset; + //qCDebug(KArchiveLog) << "end : centraldirsize: " << cdsize; buffer[16] = char(centraldiroffset); // central dir offset buffer[17] = char(centraldiroffset >> 8); @@ -1038,16 +1039,16 @@ const QString &group, qint64 /*size*/, mode_t perm, const QDateTime &accessTime, const QDateTime &modificationTime, const QDateTime &creationTime) { - //qDebug(); + //qCDebug(KArchiveLog); if (!isOpen()) { setErrorString(tr("Application error: ZIP file must be open before being written into")); - qWarning() << "doPrepareWriting failed: !isOpen()"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !isOpen()"; return false; } if (!(mode() & QIODevice::WriteOnly)) { // accept WriteOnly and ReadWrite setErrorString(tr("Application error: attempted to write into non-writable ZIP file")); - qWarning() << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; + qCWarning(KArchiveLog) << "doPrepareWriting failed: !(mode() & QIODevice::WriteOnly)"; return false; } @@ -1073,7 +1074,7 @@ if (i != -1) { QString dir = name.left(i); fileName = name.mid(i + 1); - //qDebug() << "ensuring" << dir << "exists. fileName=" << fileName; + //qCDebug(KArchiveLog) << "ensuring" << dir << "exists. fileName=" << fileName; parentDir = findOrCreate(dir); } @@ -1082,14 +1083,14 @@ // with konqi... // CAUTION: the old file itself is still in the zip and won't be removed !!! QMutableListIterator it(d->m_fileList); - //qDebug() << "fileName to write: " << name; + //qCDebug(KArchiveLog) << "fileName to write: " << name; while (it.hasNext()) { it.next(); - //qDebug() << "prepfileName: " << it.current()->path(); + //qCDebug(KArchiveLog) << "prepfileName: " << it.current()->path(); if (name == it.value()->path()) { // also remove from the parentDir parentDir->removeEntry(it.value()); - //qDebug() << "removing following entry: " << it.current()->path(); + //qCDebug(KArchiveLog) << "removing following entry: " << it.current()->path(); delete it.value(); it.remove(); } @@ -1101,7 +1102,7 @@ name, device()->pos() + 30 + name.length(), // start 0 /*size unknown yet*/, d->m_compression, 0 /*csize unknown yet*/); e->setHeaderStart(device()->pos()); - //qDebug() << "wrote file start: " << e->position() << " name: " << name; + //qCDebug(KArchiveLog) << "wrote file start: " << e->position() << " name: " << name; parentDir->addEntry(e); d->m_currentFile = e; @@ -1115,7 +1116,7 @@ // write out zip header QByteArray encodedName = QFile::encodeName(name); int bufferSize = extra_field_len + encodedName.length() + 30; - //qDebug() << "bufferSize=" << bufferSize; + //qCDebug(KArchiveLog) << "bufferSize=" << bufferSize; char *buffer = new char[bufferSize]; buffer[0] = 'P'; //local file header signature @@ -1222,15 +1223,15 @@ { if (d->m_currentFile->encoding() == 8) { // Finish - (void)d->m_currentDev->write(0, 0); + (void)d->m_currentDev->write(nullptr, 0); delete d->m_currentDev; } // If 0, d->m_currentDev was device() - don't delete ;) - d->m_currentDev = 0; + d->m_currentDev = nullptr; Q_ASSERT(d->m_currentFile); - //qDebug() << "fileName: " << d->m_currentFile->path(); - //qDebug() << "getpos (at): " << device()->pos(); + //qCDebug(KArchiveLog) << "fileName: " << d->m_currentFile->path(); + //qCDebug(KArchiveLog) << "getpos (at): " << device()->pos(); d->m_currentFile->setSize(size); int extra_field_len = 0; if (d->m_extraField == ModificationTime) { @@ -1242,14 +1243,14 @@ d->m_currentFile->headerStart() - 30 - encodedName.length() - extra_field_len; d->m_currentFile->setCompressedSize(csize); - //qDebug() << "usize: " << d->m_currentFile->size(); - //qDebug() << "csize: " << d->m_currentFile->compressedSize(); - //qDebug() << "headerstart: " << d->m_currentFile->headerStart(); + //qCDebug(KArchiveLog) << "usize: " << d->m_currentFile->size(); + //qCDebug(KArchiveLog) << "csize: " << d->m_currentFile->compressedSize(); + //qCDebug(KArchiveLog) << "headerstart: " << d->m_currentFile->headerStart(); - //qDebug() << "crc: " << d->m_crc; + //qCDebug(KArchiveLog) << "crc: " << d->m_crc; d->m_currentFile->setCRC32(d->m_crc); - d->m_currentFile = 0; + d->m_currentFile = nullptr; // update saved offset for appending new files d->m_offset = device()->pos(); @@ -1305,7 +1306,7 @@ d->m_crc = crc32(d->m_crc, (const Bytef *) data, size); qint64 written = d->m_currentDev->write(data, size); - //qDebug() << "wrote" << size << "bytes."; + //qCDebug(KArchiveLog) << "wrote" << size << "bytes."; const bool ok = written == size; if (!ok) { @@ -1427,7 +1428,7 @@ QIODevice *KZipFileEntry::createDevice() const { - //qDebug() << "creating iodevice limited to pos=" << position() << ", csize=" << compressedSize(); + //qCDebug(KArchiveLog) << "creating iodevice limited to pos=" << position() << ", csize=" << compressedSize(); // Limit the reading to the appropriate part of the underlying device (e.g. file) KLimitedIODevice *limitedDev = new KLimitedIODevice(archive()->device(), position(), compressedSize()); if (encoding() == 0 || compressedSize() == 0) { // no compression (or even no data) @@ -1440,7 +1441,7 @@ KCompressionDevice *filterDev = new KCompressionDevice(limitedDev, true, type); if (!filterDev) { - return 0; // ouch + return nullptr; // ouch } filterDev->setSkipHeaders(); // Just zlib, not gzip bool b = filterDev->open(QIODevice::ReadOnly); @@ -1449,8 +1450,8 @@ return filterDev; } - qCritical() << "This zip file contains files compressed with method" + qCCritical(KArchiveLog) << "This zip file contains files compressed with method" << encoding() << ", this method is currently not supported by KZip," << "please use a command-line tool to handle this file."; - return 0; + return nullptr; }