diff options
author | Katja Marttila <katja.marttila@qt.io> | 2023-01-03 09:55:08 +0200 |
---|---|---|
committer | Katja Marttila <katja.marttila@qt.io> | 2023-04-17 13:50:01 +0300 |
commit | 05243ce0bce0cc96b59889d15a511705c538e171 (patch) | |
tree | ebac6ee924a1002c1f68538fb18320cbdd8f229f /src | |
parent | f5a704a4694207cbbe6892e4b253a24317389e57 (diff) |
Adapt to changes in QAbstractFileEngine
Task-number: QTIFW-1829
Change-Id: I72e814cfcf852e8de47f0e772abdcb0ad9eba38f
Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/installer/binaryformat.cpp | 11 | ||||
-rw-r--r-- | src/libs/installer/binaryformat.h | 6 | ||||
-rw-r--r-- | src/libs/installer/binaryformatengine.cpp | 9 | ||||
-rw-r--r-- | src/libs/installer/binaryformatengine.h | 7 | ||||
-rw-r--r-- | src/libs/installer/remotefileengine.cpp | 23 | ||||
-rw-r--r-- | src/libs/installer/remotefileengine.h | 10 | ||||
-rw-r--r-- | src/libs/installer/remoteserverconnection.cpp | 11 |
7 files changed, 70 insertions, 7 deletions
diff --git a/src/libs/installer/binaryformat.cpp b/src/libs/installer/binaryformat.cpp index 9ed7742db..59cc5fb42 100644 --- a/src/libs/installer/binaryformat.cpp +++ b/src/libs/installer/binaryformat.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -153,12 +153,19 @@ void Resource::setName(const QByteArray &name) Opens a resource in QIODevice::ReadOnly mode. The function returns \c true if successful. */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool Resource::open() +#else +bool Resource::open(std::optional<QFile::Permissions> permissions) +#endif { if (isOpen()) return false; - +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (!m_file.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) { +#else + if (!m_file.open(QIODevice::ReadOnly | QIODevice::Unbuffered, permissions)) { +#endif setErrorString(m_file.errorString()); return false; } diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h index 26d510530..fa1becc32 100644 --- a/src/libs/installer/binaryformat.h +++ b/src/libs/installer/binaryformat.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -58,7 +58,11 @@ public: Resource(const QString &path, const Range<qint64> &segment); ~Resource(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(); +#else + bool open(std::optional<QFile::Permissions> permissions = std::nullopt); +#endif void close() override; bool seek(qint64 pos) override; diff --git a/src/libs/installer/binaryformatengine.cpp b/src/libs/installer/binaryformatengine.cpp index 681e6db79..8aa8cdca5 100644 --- a/src/libs/installer/binaryformatengine.cpp +++ b/src/libs/installer/binaryformatengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -127,9 +127,16 @@ bool BinaryFormatEngine::close() /*! \internal */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool BinaryFormatEngine::open(QIODevice::OpenMode mode) +#else +bool BinaryFormatEngine::open(QIODevice::OpenMode mode, std::optional<QFile::Permissions> permissions) +#endif { Q_UNUSED(mode) +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + Q_UNUSED(permissions) +#endif return m_resource.isNull() ? false : m_resource->open(); } diff --git a/src/libs/installer/binaryformatengine.h b/src/libs/installer/binaryformatengine.h index bf72e5f1f..169bfe0f9 100644 --- a/src/libs/installer/binaryformatengine.h +++ b/src/libs/installer/binaryformatengine.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -47,7 +47,12 @@ public: bool copy(const QString &newName) override; bool close() override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(QIODevice::OpenMode mode) override; +#else + bool open(QIODevice::OpenMode mode, + std::optional<QFile::Permissions> permissions = std::nullopt) override; +#endif qint64 pos() const override; qint64 read(char *data, qint64 maxlen) override; bool seek(qint64 offset) override; diff --git a/src/libs/installer/remotefileengine.cpp b/src/libs/installer/remotefileengine.cpp index adc5b8561..039b5196a 100644 --- a/src/libs/installer/remotefileengine.cpp +++ b/src/libs/installer/remotefileengine.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2017 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -313,6 +313,7 @@ bool RemoteFileEngine::link(const QString &newName) /*! \reimp */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectories) const { if ((const_cast<RemoteFileEngine *>(this))->connectToServer()) { @@ -320,18 +321,38 @@ bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectorie dirName, createParentDirectories); } return m_fileEngine.mkdir(dirName, createParentDirectories); + +} +#else +bool RemoteFileEngine::mkdir(const QString &dirName, bool createParentDirectories, + std::optional<QFile::Permissions> permissions) const +{ + if ((const_cast<RemoteFileEngine *>(this))->connectToServer()) { + return callRemoteMethod<bool>(QString::fromLatin1(Protocol::QAbstractFileEngineMkdir), + dirName, createParentDirectories); + } + return m_fileEngine.mkdir(dirName, createParentDirectories, permissions); } +#endif /*! \reimp */ +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool RemoteFileEngine::open(QIODevice::OpenMode mode) +#else +bool RemoteFileEngine::open(QIODevice::OpenMode mode, std::optional<QFile::Permissions> permissions) +#endif { if (connectToServer()) { return callRemoteMethod<bool>(QString::fromLatin1(Protocol::QAbstractFileEngineOpen), static_cast<qint32>(mode | QIODevice::Unbuffered)); } +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) return m_fileEngine.open(mode | QIODevice::Unbuffered); +#else + return m_fileEngine.open(mode | QIODevice::Unbuffered, permissions); +#endif } /*! diff --git a/src/libs/installer/remotefileengine.h b/src/libs/installer/remotefileengine.h index 35ebf7742..6227a0444 100644 --- a/src/libs/installer/remotefileengine.h +++ b/src/libs/installer/remotefileengine.h @@ -53,7 +53,12 @@ public: RemoteFileEngine(); ~RemoteFileEngine(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool open(QIODevice::OpenMode mode) override; +#else + bool open(QIODevice::OpenMode mode, + std::optional<QFile::Permissions> permissions = std::nullopt) override; +#endif bool close() override; bool flush() override; bool syncToDisk() override; @@ -66,7 +71,12 @@ public: bool rename(const QString &newName) override; bool renameOverwrite(const QString &newName) override; bool link(const QString &newName) override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) bool mkdir(const QString &dirName, bool createParentDirectories) const override; +#else + bool mkdir(const QString &dirName, bool createParentDirectories, + std::optional<QFile::Permissions> permissions = std::nullopt) const override; +#endif bool rmdir(const QString &dirName, bool recurseParentDirectories) const override; bool setSize(qint64 size) override; bool caseSensitive() const override; diff --git a/src/libs/installer/remoteserverconnection.cpp b/src/libs/installer/remoteserverconnection.cpp index ed3d343fe..bf4e8040c 100644 --- a/src/libs/installer/remoteserverconnection.cpp +++ b/src/libs/installer/remoteserverconnection.cpp @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 The Qt Company Ltd. +** Copyright (C) 2023 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Installer Framework. @@ -497,11 +497,20 @@ void RemoteServerConnection::handleQFSFileEngine(RemoteServerReply *reply, const bool createParentDirectories; data >>dirName; data >>createParentDirectories; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) reply->send(m_engine->mkdir(dirName, createParentDirectories)); +#else + reply->send(m_engine->mkdir(dirName, createParentDirectories, std::nullopt)); +#endif + } else if (command == QLatin1String(Protocol::QAbstractFileEngineOpen)) { qint32 openMode; data >>openMode; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) reply->send(m_engine->open(static_cast<QIODevice::OpenMode> (openMode))); +#else + reply->send(m_engine->open(static_cast<QIODevice::OpenMode> (openMode), std::nullopt)); +#endif } else if (command == QLatin1String(Protocol::QAbstractFileEngineOwner)) { qint32 owner; data >>owner; |