Return the QFileInfo::baseName/QDir::dirName() from fileEngine impl

Get those values from the file engine instead, this is relevant
especially on Android for content uris.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-98974
Change-Id: I65fe4c59e5f1feed0dcf14cc8988b4a40d9d979e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Assam Boudjelthia 2022-12-07 16:40:43 +02:00
parent d77b5fbcf1
commit f77668ffec
2 changed files with 6 additions and 2 deletions

View File

@ -661,7 +661,9 @@ QString QDir::canonicalPath() const
QString QDir::dirName() const
{
Q_D(const QDir);
return d->dirEntry.fileName();
if (!d_ptr->fileEngine)
return d->dirEntry.fileName();
return d->fileEngine->fileName(QAbstractFileEngine::BaseName);
}

View File

@ -783,7 +783,9 @@ QString QFileInfo::baseName() const
Q_D(const QFileInfo);
if (d->isDefaultConstructed)
return ""_L1;
return d->fileEntry.baseName();
if (!d_ptr->fileEngine)
return d->fileEntry.baseName();
return QFileSystemEntry(d->fileEngine->fileName(QAbstractFileEngine::BaseName)).baseName();
}
/*!