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

Uncompress method for archives

parent 7e633b56
Branches
Tags
No related merge requests found
#include <QDebug>
#include <QUrl>
#include <QUrlQuery>
#include <QMimeDatabase>
#include <QProcess>
#include "../core/config.h"
......@@ -142,8 +143,44 @@ bool XdgUrl::_installPlasmapkg(const QString &path, const QString &type)
bool XdgUrl::_uncompressArchive(const QString &path, const QString &targetDir)
{
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.
Please register or to comment