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:02 +0100 |
commit | 63312fe2ec1c1d8c0efabc02e3af8e5b47ca320e (patch) | |
tree | fc850de8f31581cc6a64db7a78d1cca479e20ce9 /src/plugins/platforms/android/androidcontentfileengine.cpp | |
parent | 5ebb03c47604e0597502fbe1069de636987f33fc (diff) | |
parent | fbebc93617d99d2bf8fed559f17dba8bed15a063 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: If36d96c0fef3de5ab6503977501c55c62a2ecc97
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; |