diff options
author | Karsten Heimrich <karsten.heimrich@theqtcompany.com> | 2015-07-10 11:54:41 +0200 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@theqtcompany.com> | 2015-07-14 11:45:04 +0000 |
commit | 7530807cb040224a2ed31e290ed6f2fb7fc75574 (patch) | |
tree | 52e06de5db9b907b63cae25abc7ac50205379702 /src/libs/installer/fileutils.cpp | |
parent | b4a2001d65e13f006da03d39e56a0d989117c597 (diff) |
Make the installation relocatable (with some limitations).
Replace the install path with a constant that's updated while
loading the stored configuration and operation values. Dynamic
variables now need to be set after reading the .ini file, cause
there we store the values we found during installation. Makes
an installation relocatable, though with some limitations:
* Uninstaller entry might break on Windows
* Start menu sortcuts might break on Windows
* Everything else written to the system using full path
Task-number: QTIFW-653
Change-Id: Ie3255299460d4ad7f18c88de9044c95db10d17ac
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/fileutils.cpp')
-rw-r--r-- | src/libs/installer/fileutils.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp index 7da62a367..8f0472a08 100644 --- a/src/libs/installer/fileutils.cpp +++ b/src/libs/installer/fileutils.cpp @@ -585,3 +585,19 @@ bool QInstaller::isInBundle(const QString &path, QString *bundlePath) #endif return false; } + +/*! + Replaces the path \a before with the path \a after at the beginning of \a path and returns + the replaced path. If \a before cannot be found in \a path, the original value is returned. +*/ +QString QInstaller::replacePath(const QString &path, const QString &before, const QString &after) +{ + if (path.isEmpty() || before.isEmpty()) + return path; + + QString pathToPatch = QDir::cleanPath(path); + const QString pathToReplace = QDir::cleanPath(before); + if (pathToPatch.startsWith(pathToReplace)) + return QDir::cleanPath(after) + pathToPatch.mid(pathToReplace.size()); + return path; +} |