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 /tests/auto | |
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 'tests/auto')
-rw-r--r-- | tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp index 7dde7e555..514df2a2e 100644 --- a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp +++ b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp @@ -121,6 +121,27 @@ private slots: } catch (...) { QFAIL("Unexpected error during create archive."); } + + try { + const QString path1 = tempSourceFile( + "Source File 1.", + QDir::tempPath() + "/temp file with spaces.XXXXXX" + ); + const QString path2 = tempSourceFile( + "Source File 2.", + QDir::tempPath() + "/temp file with spaces.XXXXXX" + ); + + QTemporaryFile target(QDir::tempPath() + "/target file with spaces.XXXXXX"); + QVERIFY(target.open()); + Lib7z::createArchive(&target, QStringList() << path1 << path2); + QCOMPARE(Lib7z::listArchive(&target).count(), 2); + } catch (const Lib7z::SevenZipException& e) { + QFAIL(e.message().toUtf8()); + } catch (...) { + QFAIL("Unexpected error during create archive."); + } + } void testExtractArchive() @@ -139,9 +160,12 @@ private slots: } private: - QString tempSourceFile(const QByteArray &data) + QString tempSourceFile(const QByteArray &data, const QString &templateName = QString()) { QTemporaryFile source; + if (!templateName.isEmpty()) { + source.setFileTemplate(templateName); + } source.open(); source.write(data); source.setAutoRemove(false); |