diff options
Diffstat (limited to 'src/corelib/io/qfsfileengine_p.h')
-rw-r--r-- | src/corelib/io/qfsfileengine_p.h | 87 |
1 files changed, 39 insertions, 48 deletions
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h index d6e7ecb592..dfc40e20b6 100644 --- a/src/corelib/io/qfsfileengine_p.h +++ b/src/corelib/io/qfsfileengine_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFSFILEENGINE_P_H #define QFSFILEENGINE_P_H @@ -57,6 +21,12 @@ #include <QtCore/private/qfilesystemmetadata_p.h> #include <qhash.h> +#include <optional> + +#ifdef Q_OS_UNIX +#include <sys/types.h> // for mode_t +#endif + #ifndef QT_NO_FSFILEENGINE QT_BEGIN_NAMESPACE @@ -79,7 +49,7 @@ public: explicit QFSFileEngine(const QString &file); ~QFSFileEngine(); - bool open(QIODevice::OpenMode openMode) override; + bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions) override; bool open(QIODevice::OpenMode flags, FILE *fh); bool close() override; bool flush() override; @@ -90,10 +60,15 @@ public: bool isSequential() const override; bool remove() override; bool copy(const QString &newName) override; - bool rename(const QString &newName) override; - bool renameOverwrite(const QString &newName) override; + + bool rename(const QString &newName) override + { return rename_helper(newName, Rename); } + bool renameOverwrite(const QString &newName) override + { return rename_helper(newName, RenameOverwrite); } + bool link(const QString &newName) override; - bool mkdir(const QString &dirName, bool createParentDirectories) const override; + bool mkdir(const QString &dirName, bool createParentDirectories, + std::optional<QFile::Permissions> permissions) const override; bool rmdir(const QString &dirName, bool recurseParentDirectories) const override; bool setSize(qint64 size) override; bool caseSensitive() const override; @@ -105,14 +80,15 @@ public: QString fileName(FileName file) const override; uint ownerId(FileOwner) const override; QString owner(FileOwner) const override; - bool setFileTime(const QDateTime &newDate, FileTime time) override; - QDateTime fileTime(FileTime time) const override; + bool setFileTime(const QDateTime &newDate, QFile::FileTime time) override; + QDateTime fileTime(QFile::FileTime time) const override; void setFileName(const QString &file) override; + void setFileEntry(QFileSystemEntry &&entry); int handle() const override; #ifndef QT_NO_FILESYSTEMITERATOR - Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override; - Iterator *endEntryList() override; + IteratorUniquePtr beginEntryList(const QString &path, QDir::Filters filters, + const QStringList &filterNames) override; #endif qint64 read(char *data, qint64 maxlen) override; @@ -139,6 +115,10 @@ public: protected: QFSFileEngine(QFSFileEnginePrivate &dd); + +private: + enum RenameMode : int { Rename, RenameOverwrite }; + bool rename_helper(const QString &newName, RenameMode mode); }; class Q_AUTOTEST_EXPORT QFSFileEnginePrivate : public QAbstractFileEnginePrivate @@ -153,7 +133,7 @@ public: QFileSystemEntry fileEntry; QIODevice::OpenMode openMode; - bool nativeOpen(QIODevice::OpenMode openMode); + bool nativeOpen(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions); bool openFh(QIODevice::OpenMode flags, FILE *fh); bool openFd(QIODevice::OpenMode flags, int fd); bool nativeClose(); @@ -180,6 +160,9 @@ public: #ifndef Q_OS_WIN bool isSequentialFdFh() const; #endif +#ifdef Q_OS_WIN + bool nativeRenameOverwrite(const QFileSystemEntry &newEntry); +#endif uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags); bool unmap(uchar *ptr); @@ -197,7 +180,11 @@ public: mutable int cachedFd; mutable DWORD fileAttrib; #else - QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps; + struct StartAndLength { + int start; // offset % PageSize + size_t length; // length + offset % PageSize + }; + QHash<uchar *, StartAndLength> maps; #endif int fd; @@ -239,6 +226,10 @@ protected: void init(); QAbstractFileEngine::FileFlags getPermissions(QAbstractFileEngine::FileFlags type) const; + +#ifdef Q_OS_UNIX + bool nativeOpenImpl(QIODevice::OpenMode openMode, mode_t mode); +#endif }; QT_END_NAMESPACE |