diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-03-01 01:00:23 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-03 14:13:53 +0100 |
commit | 2f2d870fdd1e99d27fda6fa986f7de8a17ad0edf (patch) | |
tree | 00c1ec03ae3e2a1f3971543dc975598a36cc12c6 /src/plugins/platforms/android/androidcontentfileengine.cpp | |
parent | bbe71efc23334ae928b887555d9cdee30fa826e3 (diff) | |
parent | 63312fe2ec1c1d8c0efabc02e3af8e5b47ca320e (diff) |
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'src/plugins/platforms/android/androidcontentfileengine.cpp')
-rw-r--r-- | src/plugins/platforms/android/androidcontentfileengine.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/src/plugins/platforms/android/androidcontentfileengine.cpp b/src/plugins/platforms/android/androidcontentfileengine.cpp index 1444407195..3e3bdc2592 100644 --- a/src/plugins/platforms/android/androidcontentfileengine.cpp +++ b/src/plugins/platforms/android/androidcontentfileengine.cpp @@ -44,9 +44,10 @@ #include <QDebug> -AndroidContentFileEngine::AndroidContentFileEngine(const QString &fileName) - : QFSFileEngine(fileName) +AndroidContentFileEngine::AndroidContentFileEngine(const QString &f) + : m_file(f) { + setFileName(f); } bool AndroidContentFileEngine::open(QIODevice::OpenMode openMode) @@ -78,6 +79,48 @@ bool AndroidContentFileEngine::open(QIODevice::OpenMode openMode) return QFSFileEngine::open(openMode, fd, QFile::AutoCloseHandle); } +qint64 AndroidContentFileEngine::size() const +{ + const jlong size = QJNIObjectPrivate::callStaticMethod<jlong>( + "org/qtproject/qt5/android/QtNative", "getSize", + "(Landroid/content/Context;Ljava/lang/String;)J", QtAndroidPrivate::context(), + QJNIObjectPrivate::fromString(fileName(DefaultName)).object()); + return (qint64)size; +} + +AndroidContentFileEngine::FileFlags AndroidContentFileEngine::fileFlags(FileFlags type) const +{ + FileFlags commonFlags(ReadOwnerPerm|ReadUserPerm|ReadGroupPerm|ReadOtherPerm|ExistsFlag); + FileFlags flags; + const bool exists = QJNIObjectPrivate::callStaticMethod<jboolean>( + "org/qtproject/qt5/android/QtNative", "checkFileExists", + "(Landroid/content/Context;Ljava/lang/String;)Z", QtAndroidPrivate::context(), + QJNIObjectPrivate::fromString(fileName(DefaultName)).object()); + if (!exists) + return flags; + flags = FileType | commonFlags; + return type & flags; +} + +QString AndroidContentFileEngine::fileName(FileName f) const +{ + switch (f) { + case PathName: + case AbsolutePathName: + case CanonicalPathName: + case DefaultName: + case AbsoluteName: + case CanonicalName: + return m_file; + case BaseName: + { + const int pos = m_file.lastIndexOf(QChar(QLatin1Char('/'))); + return m_file.mid(pos); + } + default: + return QString(); + } +} AndroidContentFileEngineHandler::AndroidContentFileEngineHandler() = default; AndroidContentFileEngineHandler::~AndroidContentFileEngineHandler() = default; |