summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <[email protected]>2016-03-29 20:20:31 +0200
committerRagnar Thomsen <[email protected]>2016-03-29 21:52:36 +0200
commit045a847d27e2fed3eab56eb2fffe532b70d1bc8d (patch)
treec7845ebf65710a5c9dbf80c1d5f29fcfb622494e
parentdf39ac39da7251faaedc3fefe701ab7f951ff4fe (diff)
Set compression level in libarchiveplugin
Summary: This sets compression level in libarchiveplugin if CompressionLevel is passed in CompressionOptions. Reviewers: elvisangelaccio Reviewed By: elvisangelaccio Subscribers: kde-utils-devel Projects: #ark Differential Revision: https://phabricator.kde.org/D1256
-rw-r--r--plugins/libarchive/readwritelibarchiveplugin.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/libarchive/readwritelibarchiveplugin.cpp b/plugins/libarchive/readwritelibarchiveplugin.cpp
index 083939b..5e2ad40 100644
--- a/plugins/libarchive/readwritelibarchiveplugin.cpp
+++ b/plugins/libarchive/readwritelibarchiveplugin.cpp
@@ -184,6 +184,18 @@ bool ReadWriteLibarchivePlugin::addFiles(const QStringList& files, const Compres
QLatin1String(archive_error_string(arch_writer.data()))));
return false;
}
+
+ // Set compression level if passed in CompressionOptions.
+ if (options.contains(QStringLiteral("CompressionLevel"))) {
+ qCDebug(ARK) << "Using compression level:" << options.value(QStringLiteral("CompressionLevel")).toString();
+ ret = archive_write_set_filter_option(arch_writer.data(), NULL, "compression-level", options.value(QStringLiteral("CompressionLevel")).toString().toUtf8());
+ if (ret != ARCHIVE_OK) {
+ qCWarning(ARK) << "Failed to set compression level";
+ emit error(xi18nc("@info", "Setting the compression level failed with the following error:<nl/><message>%1</message>",
+ QLatin1String(archive_error_string(arch_writer.data()))));
+ return false;
+ }
+ }
}
ret = archive_write_open_fd(arch_writer.data(), tempFile.handle());