Skip to content
Snippets Groups Projects
Commit b23d2edd authored by akiraohgaki's avatar akiraohgaki
Browse files

Uncompress method for archives

parent 7e633b56
No related branches found
No related tags found
No related merge requests found
#include <QDebug>
#include <QUrl>
#include <QUrlQuery>
#include <QMimeDatabase>
#include <QProcess>
#include "../core/config.h"
......@@ -142,7 +143,43 @@ bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type)
bool XdgUrl::_uncompressArchive(const QString &path, const QString &targetDir)
{
return true;
QMimeDatabase mimeDb;
QString mimeType = mimeDb.mimeTypeForFile(path).name();
QString archiveType;
QProcess process;
QString program;
QStringList arguments;
if (_archiveTypes.contains(mimeType)) {
archiveType = _archiveTypes[mimeType].toString();
if (archiveType == "tar") {
program = "tar";
arguments << "-xf" << path << "-C" << targetDir;
}
else if (archiveType == "zip") {
program = "unzip";
arguments << "-o" << path << "-d" << targetDir;
}
else if (archiveType == "7z") {
program = "7z";
arguments << "x" << path << "-o" + targetDir; // No space between -o and directory
}
else if (archiveType == "rar") {
program = "unrar";
arguments << "e" << path << targetDir;
}
process.start(program, arguments);
if (process.waitForFinished()) {
process.waitForReadyRead();
return true;
}
}
return false;
}
bool XdgUrl::_download()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment