diff options
| author | Eran Mizrahi <erasmux@gmail.com> | 2017-12-27 00:17:18 +0200 |
|---|---|---|
| committer | Eran Mizrahi <erasmux@gmail.com> | 2017-12-27 02:41:43 +0200 |
| commit | d41cd8d877223db1f35c12667bf59966d4d377cc (patch) | |
| tree | 8e04522f89061cc9b351bd20a2ac22e1b686ba3e /src/organizercore.cpp | |
| parent | 9c82a1102e54b7fb350e18bd52cbf81083f42ca7 (diff) | |
Virtualize spawning of executable also if working directory is under mods folder
Diffstat (limited to 'src/organizercore.cpp')
| -rw-r--r-- | src/organizercore.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 7668485c..121de21a 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1196,30 +1196,35 @@ HANDLE OrganizerCore::spawnBinaryProcess(const QFileInfo &binary, QString modsPath = settings().getModDirectory();
+ // Check if this a request with either an executable or a working directory under our mods folder
+ // then will start the processs in a virtualized "environment" with the appropriate paths fixed:
+ // (i.e. mods\FNIS\path\exe => game\data\path\exe)
+ QString cwdPath = currentDirectory.absolutePath();
+ bool virtualizedCwd = cwdPath.startsWith(modsPath, Qt::CaseInsensitive);
QString binPath = binary.absoluteFilePath();
- if (binPath.startsWith(modsPath, Qt::CaseInsensitive)) {
- // binary was installed as a MO mod. Need to start it through a (hooked)
- // proxy to ensure pathes are correct
+ bool virtualizedBin = binPath.startsWith(modsPath, Qt::CaseInsensitive);
+ if (virtualizedCwd || virtualizedBin) {
+ if (virtualizedCwd) {
+ int cwdOffset = cwdPath.indexOf('/', modsPath.length() + 1);
+ cwdPath = m_GamePlugin->dataDirectory().absolutePath() + cwdPath.mid(cwdOffset, -1);
+ }
- QString cwdPath = currentDirectory.absolutePath();
+ if (virtualizedBin) {
+ int binOffset = binPath.indexOf('/', modsPath.length() + 1);
+ binPath = m_GamePlugin->dataDirectory().absolutePath() + binPath.mid(binOffset, -1);
+ }
- int binOffset = binPath.indexOf('/', modsPath.length() + 1);
- int cwdOffset = cwdPath.indexOf('/', modsPath.length() + 1);
- QString dataBinPath = m_GamePlugin->dataDirectory().absolutePath()
- + binPath.mid(binOffset, -1);
- QString dataCwd = m_GamePlugin->dataDirectory().absolutePath()
- + cwdPath.mid(cwdOffset, -1);
QString cmdline
= QString("launch \"%1\" \"%2\" %3")
- .arg(QDir::toNativeSeparators(dataCwd),
- QDir::toNativeSeparators(dataBinPath), arguments);
+ .arg(QDir::toNativeSeparators(cwdPath),
+ QDir::toNativeSeparators(binPath), arguments);
qDebug() << "Spawning proxyed process <" << cmdline << ">";
return startBinary(QFileInfo(QCoreApplication::applicationFilePath()),
cmdline, QCoreApplication::applicationDirPath(), true);
} else {
- qDebug() << "Spawning direct process <" << binary.absoluteFilePath() << "," << arguments << "," << currentDirectory.absolutePath() << ">";
+ qDebug() << "Spawning direct process <" << binPath << "," << arguments << "," << cwdPath << ">";
return startBinary(binary, arguments, currentDirectory, true);
}
} else {
|
