forked from qt-creator/qt-creator
Utils: avoid QFileInfo in FilePath::fromStringWithExtension
Change-Id: I853e678e98af09a53d1165c51cf00377df1b7f4d Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -899,16 +899,15 @@ FilePath FilePath::fromStringWithExtension(const QString &filepath, const QStrin
|
||||
if (filepath.isEmpty() || defaultExtension.isEmpty())
|
||||
return FilePath::fromString(filepath);
|
||||
|
||||
QString rc = filepath;
|
||||
QFileInfo fi(filepath);
|
||||
FilePath rc = FilePath::fromString(filepath);
|
||||
// Add extension unless user specified something else
|
||||
const QChar dot = QLatin1Char('.');
|
||||
if (!fi.fileName().contains(dot)) {
|
||||
if (!rc.fileName().contains(dot)) {
|
||||
if (!defaultExtension.startsWith(dot))
|
||||
rc += dot;
|
||||
rc += defaultExtension;
|
||||
rc.stringAppended(dot);
|
||||
rc.stringAppended(defaultExtension);
|
||||
}
|
||||
return FilePath::fromString(rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/// Constructs a FilePath from \a filePath
|
||||
|
Reference in New Issue
Block a user