forked from qt-creator/qt-creator
QMakeProject: Fix inconsistent isAbsolutePath
The QMakeEvaluator uses it's own more accurate version of isAbsolutePath. If we pass in a path that qt thinks is absolute, e.g. "C:dev", but the qmake evaluator disagrees, creator crashes. Import these functions from the qmake evaluator into Utils::FileUtils and use them to prepare the builddirectory. Task-number: QTCREATORBUG-12034 Change-Id: Ida28688558f3186db25e3ab73bd39cabc91c1ff0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -289,6 +289,32 @@ QString FileUtils::normalizePathName(const QString &name)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool FileUtils::isRelativePath(const QString &path)
|
||||
{
|
||||
if (path.startsWith(QLatin1Char('/')))
|
||||
return false;
|
||||
#ifdef Q_OS_WIN
|
||||
if (path.startsWith(QLatin1Char('\\')))
|
||||
return false;
|
||||
// Unlike QFileInfo, this won't accept a relative path with a drive letter.
|
||||
// Such paths result in a royal mess anyway ...
|
||||
if (path.length() >= 3 && path.at(1) == QLatin1Char(':') && path.at(0).isLetter()
|
||||
&& (path.at(2) == QLatin1Char('/') || path.at(2) == QLatin1Char('\\')))
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
QString FileUtils::resolvePath(const QString &baseDir, const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty())
|
||||
return QString();
|
||||
if (isAbsolutePath(fileName))
|
||||
return QDir::cleanPath(fileName);
|
||||
return QDir::cleanPath(baseDir + QLatin1Char('/') + fileName);
|
||||
}
|
||||
|
||||
|
||||
QByteArray FileReader::fetchQrc(const QString &fileName)
|
||||
{
|
||||
QTC_ASSERT(fileName.startsWith(QLatin1Char(':')), return QByteArray());
|
||||
|
||||
Reference in New Issue
Block a user