diff options
| author | AL <26797547+Al12rs@users.noreply.github.com> | 2020-08-26 01:09:26 +0200 |
|---|---|---|
| committer | AL <26797547+Al12rs@users.noreply.github.com> | 2020-08-26 01:09:26 +0200 |
| commit | ba1ff53c1b98f0d4d8534175c24a2c0f1355da33 (patch) | |
| tree | d4adac41b8b53b67b3fa266fb76ea638cff15027 /src | |
| parent | 6f232d566e9a7b67eae0cef4aaa46938072b3c20 (diff) | |
Use trailing slashes to make accurate comparisons in adjustForVirtualized.
Diffstat (limited to 'src')
| -rw-r--r-- | src/processrunner.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/processrunner.cpp b/src/processrunner.cpp index 3ea40da2..97b5c580 100644 --- a/src/processrunner.cpp +++ b/src/processrunner.cpp @@ -19,12 +19,16 @@ void adjustForVirtualized( // "environment" with the appropriate paths fixed: // (i.e. mods\FNIS\path\exe => game\data\path\exe) QString cwdPath = sp.currentDirectory.absolutePath(); - bool virtualizedCwd = cwdPath.startsWith(modsPath, Qt::CaseInsensitive); + QString trailedModsPath = modsPath; + if (!trailedModsPath.endsWith('/')) { + trailedModsPath = trailedModsPath + '/'; + } + bool virtualizedCwd = cwdPath.startsWith(trailedModsPath, Qt::CaseInsensitive); QString binPath = sp.binary.absoluteFilePath(); - bool virtualizedBin = binPath.startsWith(modsPath, Qt::CaseInsensitive); + bool virtualizedBin = binPath.startsWith(trailedModsPath, Qt::CaseInsensitive); if (virtualizedCwd || virtualizedBin) { if (virtualizedCwd) { - int cwdOffset = cwdPath.indexOf('/', modsPath.length() + 1); + int cwdOffset = cwdPath.indexOf('/', trailedModsPath.length()); QString adjustedCwd = cwdPath.mid(cwdOffset, -1); cwdPath = game->dataDirectory().absolutePath(); if (cwdOffset >= 0) @@ -33,7 +37,7 @@ void adjustForVirtualized( } if (virtualizedBin) { - int binOffset = binPath.indexOf('/', modsPath.length() + 1); + int binOffset = binPath.indexOf('/', trailedModsPath.length()); QString adjustedBin = binPath.mid(binOffset, -1); binPath = game->dataDirectory().absolutePath(); if (binOffset >= 0) |
