summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/lib7z_facade.cpp
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-06-09 12:00:40 +0200
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-06-10 08:16:01 +0000
commit0aab7c6d68e6ba7921594fc965a410baf7662996 (patch)
tree6d0d3a048371baa088b684d84cd06c105473ed45 /src/libs/installer/lib7z_facade.cpp
parent02f1c6cde87c23c187111c1ccc6c9bc4c04e698f (diff)
Implement option to pass compression level, update documentation.
Change-Id: Iaffbd0de5590131287f5e9414f13d3906b8b3d14 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/lib7z_facade.cpp')
-rw-r--r--src/libs/installer/lib7z_facade.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index cb3f88610..cc1ee58af 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -873,9 +873,10 @@ static QString createTmp7z()
}
/*!
- Creates an archive using the the given file device \a archive. \a sourcePaths can contain
- one or more files, one or more directories or a combination of files and folders. Also the
- \c * wildcard is supported.The \a callback can be used to get information about the archive
+ Creates an archive using the given file device \a archive. \a sourcePaths can contain one or
+ more files, one or more directories or a combination of files and folders. The \c * wildcard
+ is supported also. The value of \a level specifies the compression ratio, the default is set
+ to \c 5 (Normal compression). The \a callback can be used to get information about the archive
creation process. If no \a callback is given, an empty implementation is used.
\note Throws SevenZipException on error.
@@ -883,12 +884,12 @@ static QString createTmp7z()
\note The ownership of \a callback is transferred to the function and gets delete on exit.
*/
void INSTALLER_EXPORT createArchive(QFileDevice *archive, const QStringList &sources,
- UpdateCallback *callback)
+ Compression level, UpdateCallback *callback)
{
LIB7Z_ASSERTS(archive, Writable)
const QString tmpArchive = createTmp7z();
- Lib7z::createArchive(tmpArchive, sources, QTmpFile::No, callback);
+ Lib7z::createArchive(tmpArchive, sources, QTmpFile::No, level, callback);
try {
QFile source(tmpArchive);
@@ -903,8 +904,9 @@ void INSTALLER_EXPORT createArchive(QFileDevice *archive, const QStringList &sou
Creates an archive with the given filename \a archive. \a sourcePaths can contain one or more
files, one or more directories or a combination of files and folders. Also the \c * wildcard
is supported. To be able to use the function during an elevated installation, set \a mode to
- \c QTmpFile::Yes. The \a callback can be used to get information about the archive creation
- process. If no \a callback is given, an empty implementation is used.
+ \c QTmpFile::Yes. The value of \a level specifies the compression ratio, the default is set
+ to \c 5 (Normal compression). The \a callback can be used to get information about the archive
+ creation process. If no \a callback is given, an empty implementation is used.
\note Throws SevenZipException on error.
\note If \a archive exists, it will be overwritten.
@@ -912,7 +914,7 @@ void INSTALLER_EXPORT createArchive(QFileDevice *archive, const QStringList &sou
\note The ownership of \a callback is transferred to the function and gets delete on exit.
*/
void createArchive(const QString &archive, const QStringList &sources, QTmpFile mode,
- UpdateCallback *callback)
+ Compression level, UpdateCallback *callback)
{
try {
QString target = archive;
@@ -925,6 +927,7 @@ void createArchive(const QString &archive, const QStringList &sources, QTmpFile
#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(' ')))
);