adding a compressiondevice...sorta
This commit is contained in:
parent
fbdd31ff2b
commit
c36855c0d5
1 changed files with 10 additions and 2 deletions
|
@ -1,9 +1,11 @@
|
||||||
#include "filemanager.h"
|
#include "filemanager.h"
|
||||||
#include <ktar.h>
|
#include <ktar.h>
|
||||||
|
#include <KCompressionDevice>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QTemporaryFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
File::File(QObject *parent)
|
File::File(QObject *parent)
|
||||||
|
@ -63,12 +65,12 @@ bool File::save(QUrl file, QVariantList serviceList) {
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkpath("/tmp/presenter");
|
dir.mkpath("/tmp/presenter");
|
||||||
QFile jsonFile("/tmp/presenter/json");
|
QTemporaryFile jsonFile;
|
||||||
|
|
||||||
if (!jsonFile.exists())
|
if (!jsonFile.exists())
|
||||||
qDebug() << "NOT EXISTS!";
|
qDebug() << "NOT EXISTS!";
|
||||||
|
|
||||||
if (!jsonFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
if (!jsonFile.open())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//finalize the temp json file, in case something goes wrong in the
|
//finalize the temp json file, in case something goes wrong in the
|
||||||
|
@ -81,6 +83,11 @@ bool File::save(QUrl file, QVariantList serviceList) {
|
||||||
QString filename = file.toString().right(file.toString().size() - 7);
|
QString filename = file.toString().right(file.toString().size() - 7);
|
||||||
qDebug() << filename;
|
qDebug() << filename;
|
||||||
|
|
||||||
|
KCompressionDevice dev(filename, KCompressionDevice::Zstd);
|
||||||
|
if (!dev.open(QIODevice::WriteOnly)) {
|
||||||
|
qDebug() << dev.isOpen();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
KTar tar(filename, "application/zstd");
|
KTar tar(filename, "application/zstd");
|
||||||
|
|
||||||
if (!tar.open(QIODevice::WriteOnly)) {
|
if (!tar.open(QIODevice::WriteOnly)) {
|
||||||
|
@ -113,6 +120,7 @@ bool File::save(QUrl file, QVariantList serviceList) {
|
||||||
|
|
||||||
//close the archive so that everything is done
|
//close the archive so that everything is done
|
||||||
tar.close();
|
tar.close();
|
||||||
|
dev.close();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue