forked from qt-creator/qt-creator
Make sure to generate qmake friendly file names
According to Ossi the only safe characters in a path for qmake are alphanumerical, underscore, dot and dash. Task-number: QTCREATORBUG-10980 Change-Id: Ibacbfeb7f04f1f0524093f1d8fce637ea4ae6fd6 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -236,6 +236,25 @@ QString FileUtils::fileSystemFriendlyName(const QString &name)
|
||||
return result;
|
||||
}
|
||||
|
||||
int FileUtils::indexOfQmakeUnfriendly(const QString &name, int startpos)
|
||||
{
|
||||
static QRegExp checkRegExp(QLatin1String("[^a-zA-Z0-9_.-]"));
|
||||
return checkRegExp.indexIn(name, startpos);
|
||||
}
|
||||
|
||||
QString FileUtils::qmakeFriendlyName(const QString &name)
|
||||
{
|
||||
QString result = name;
|
||||
|
||||
// Remove characters that might trip up a build system (especially qmake):
|
||||
int pos = indexOfQmakeUnfriendly(result);
|
||||
while (pos >= 0) {
|
||||
result[pos] = QLatin1Char('_');
|
||||
pos = indexOfQmakeUnfriendly(result, pos);
|
||||
}
|
||||
return fileSystemFriendlyName(result);
|
||||
}
|
||||
|
||||
bool FileUtils::makeWritable(const FileName &path)
|
||||
{
|
||||
const QString fileName = path.toString();
|
||||
|
||||
Reference in New Issue
Block a user