Skip to content

Commit

Permalink
Don't add prefix for BaseName
Browse files Browse the repository at this point in the history
Adding the "assets:" prefix to BaseName leads to wrong names returned by
QFileInfo{"assets:/path/to/file"}.fileName().
Instead to return "file" it returns "assets:/file" which is not the
expected result.

Fixes: QTBUG-114576
Fixes: QTBUG-114219
Fixes: QTBUG-112261
Pick-to: 6.6 6.5 6.5.2
Change-Id: I574bf325300c0aedef68b1b183fa837144ad63c6
Reviewed-by: Assam Boudjelthia <[email protected]>
  • Loading branch information
bog-dan-ro committed Jun 16, 2023
1 parent 77d0f37 commit 76619ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ class AndroidAbstractFileEngine: public QAbstractFileEngine
return prefixedPath(m_fileName);
case BaseName:
if ((pos = m_fileName.lastIndexOf(u'/')) != -1)
return prefixedPath(m_fileName.mid(pos));
return m_fileName.mid(pos + 1);
else
return prefixedPath(m_fileName);
return m_fileName;
case PathName:
case AbsolutePathName:
case CanonicalPathName:
Expand Down
12 changes: 9 additions & 3 deletions tests/auto/corelib/platform/android/tst_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <qpa/qplatformnativeinterface.h>
#include <QtCore/qdiriterator.h>

using namespace Qt::StringLiterals;

class tst_Android : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -64,10 +66,14 @@ void tst_Android::assetsIterating()

QDirIterator it("assets:/top_level_dir", QDirIterator::Subdirectories);
QStringList iteratorAssets;
while (it.hasNext())
iteratorAssets.append(it.next());
while (it.hasNext())
iteratorAssets.append(it.next());

QVERIFY(assets == iteratorAssets);

QVERIFY(assets == iteratorAssets);
auto entryList = QDir{"assets:/"_L1}.entryList(QStringList{"*.txt"_L1});
QCOMPARE(entryList.size(), 1);
QCOMPARE(entryList[0], "test.txt"_L1);
}

void tst_Android::testAndroidSdkVersion()
Expand Down

0 comments on commit 76619ea

Please sign in to comment.