diff options
author | Frerich Raabe <raabe@froglogic.com> | 2015-11-19 12:26:20 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@theqtcompany.com> | 2015-12-08 13:06:49 +0000 |
commit | 5e28f85a886e1e28edc0370f15b777bbf2b2a557 (patch) | |
tree | d1cd5c2d1e9b627f7b2f5b0caf621a19a94f93e8 /src/libs/installer/lib7z_facade.cpp | |
parent | 1963986ba756faca9a33d727563be1a5962191a8 (diff) |
Fixed running binarycreator if the temporary directory name contains spaces
The binarycreator program fails to generate an archive if the temporary
directory name contains spaces. This is not uncommon on Windows since
the temporary directory is beneath the home directory, e.g.
C:\Users\<username>\AppData\Local\Temp. If the user name contains spaces
(as it does in my case, the user name is "Frerich Raabe") binarycreator
fails with
[64] Warning: QFile::remove: Empty or null file name (C:\Qt\MSVC12\5.5.0-src\qtbase\src\corelib\io\qfile.cpp:498, bool __thiscall QFile::remove(void))
Caught exception: Cannot create archive "C:\Users\Frerich": internal code: E_FAIL
This was caused by createArchive() assembling a command line without
escaping either the 'target' or any of the 'sources' values.
Instead of adding escaping only to split the command line again, let's
drop the approach of constructing a command and then splitting it
completely. Instead, let's build an array of arguments right away.
Change-Id: I284c1b5a27e9edd3717243ea7979149ab2033d64
Task-number: QTIFW-787
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/lib7z_facade.cpp')
-rw-r--r-- | src/libs/installer/lib7z_facade.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp index 458bf5770..a5a038d91 100644 --- a/src/libs/installer/lib7z_facade.cpp +++ b/src/libs/installer/lib7z_facade.cpp @@ -46,8 +46,6 @@ # include "StdAfx.h" #endif -#include <Common/CommandLineParser.h> - #include <7zCrc.h> #include <7zip/Archive/IArchive.h> @@ -930,21 +928,22 @@ void createArchive(const QString &archive, const QStringList &sources, QTmpFile if (mode == QTmpFile::Yes) target = createTmp7z(); - const UString command = QString2UString( - // (mode: add) (type: 7z) (time: modified|creation|access) (threads: multi-threaded) - QLatin1String("a -t7z -mtm=on -mtc=on -mta=on -mmt=on ") -#ifdef Q_OS_WIN - + QLatin1String("-sccUTF-8 ") // (files: case-sensitive|UTF8) -#endif - + QString::fromLatin1("-mx=%1 ").arg(int(level)) // (compression: level) - + QDir::toNativeSeparators(target) + QLatin1Char(' ') - + QDir::toNativeSeparators(sources.join(QLatin1Char(' '))) - ); - CArcCmdLineOptions options; try { UStringVector commandStrings; - NCommandLineParser::SplitCommandLine(command, commandStrings); + commandStrings.Add(L"a"); // mode: add + commandStrings.Add(L"-t7z"); // type: 7z + commandStrings.Add(L"-mtm=on"); // time: modeifier|creation|access + commandStrings.Add(L"-mtc=on"); + commandStrings.Add(L"-mta=on"); + commandStrings.Add(L"-mmt=on"); // threads: multi-threaded +#ifdef Q_OS_WIN + commandStrings.Add(L"-sccUTF-8"); // files: case-sensitive|UTF8 +#endif + commandStrings.Add(QString2UString(QString::fromLatin1("-mx=%1").arg(int(level)))); // compression: level + commandStrings.Add(QString2UString(QDir::toNativeSeparators(target))); + foreach (const QString &source, sources) + commandStrings.Add(QString2UString(source)); CArcCmdLineParser parser; parser.Parse1(commandStrings, options); |