Add support for powershell Expand-Archive for archives

This will work with any Windows 10 installation.

Change-Id: Ia7ca25a5ba4e199ccfc37138e228c4d56f0f8a6a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Thomas Hartmann
2021-02-22 14:55:53 +01:00
parent 08e1893f0b
commit c22ed5528d

View File

@@ -45,6 +45,7 @@ struct Tool
QStringList arguments;
QStringList supportedMimeTypes;
QStringList additionalSearchDirs;
bool nativeWindowsArguments = false;
};
static QStringList additionalInstallDirs(const QString &registryKey, const QString &valueName)
@@ -64,6 +65,13 @@ static const QVector<Tool> &sTools()
{
static QVector<Tool> tools;
if (tools.isEmpty()) {
if (Utils::HostOsInfo::isWindowsHost()) {
tools << Tool{{"powershell"},
{"-command Expand-Archive -Force '%{src}' '%{dest}'"},
{"application/zip"},
{},
true};
}
tools << Tool{{"unzip"}, {"-o", "%{src}", "-d", "%{dest}"}, {"application/zip"}, {}};
tools << Tool{{"7z"},
{"x", "-o%{dest}", "-y", "-bb", "%{src}"},
@@ -247,7 +255,15 @@ Archive *Archive::unarchive(const FilePath &src, const FilePath &dest)
workingDirectory));
});
archive->m_process->setProgram(tool->executable);
#ifdef Q_OS_WIN
if (!tool->nativeWindowsArguments)
archive->m_process->setArguments(tool->arguments);
else if (!tool->arguments.isEmpty())
archive->m_process->setNativeArguments(tool->arguments.at(0));
#else
archive->m_process->setArguments(tool->arguments);
#endif
archive->m_process->setWorkingDirectory(workingDirectory);
archive->m_process->start(QProcess::ReadOnly);
return archive;