PE: Be more restrictive in fixupDir()

Only modify device letter if it appears to be one.
Do not touch capitilization when fixing.
Amends b6dd53d4ed.

Change-Id: I55203eb14bc78d551dd4d88cd2a4e3efac3d816e
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2021-08-05 07:34:49 +02:00
parent bd5c36530b
commit 3560d98cc1

View File

@@ -134,22 +134,18 @@ void BuildDirectoryAspect::addToLayout(LayoutBuilder &builder)
FilePath BuildDirectoryAspect::fixupDir(const FilePath &dir)
{
if (dir.needsDevice() || !HostOsInfo::isWindowsHost())
if (!dir.startsWithDriveLetter())
return {};
const QString dirString = dir.toString().toLower();
if (dirString.length() < 2)
return {};
if (!dirString.at(0).isLetter())
return {};
const QStringList drives = Utils::transform(QDir::drives(), [](const QFileInfo &fi) {
return fi.absoluteFilePath().toLower().chopped(1);
});
if (!Utils::contains(drives, [&dirString](const QString &drive) {
return dirString.startsWith(drive);
}) && !drives.isEmpty()) {
QString newDir = dirString;
QString newDir = dir.path();
newDir.replace(0, 2, drives.first());
return FilePath::fromString(newDir);
return dir.withNewPath(newDir);
}
return {};
}