Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmlocalfileengine_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 Qt Group
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QWASMLOCALFILEENGINE_P_H
4#define QWASMLOCALFILEENGINE_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists for the convenience
11// of other Qt classes. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <QtCore/private/qabstractfileengine_p.h>
18#include <QtCore/private/qstdweb_p.h>
19
20QT_BEGIN_NAMESPACE
21
22class QWasmFileEngine;
23
25{
26public:
28
30 virtual ~QWasmFileEngineHandler() override;
31 virtual std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const override;
32
33 static bool isWasmFileName(const QString& fileName);
34 static QString makeWasmFileName(const QString &fileName);
35 static QString nativeFileName(const QString &wasmFileName);
36
37 static QString addFile(qstdweb::File file);
38 static QString addFile(qstdweb::FileSystemFileHandle file);
39 static void removeFile(const QString fileName);
40 qstdweb::File getFile(const QString fileName);
41 qstdweb::FileSystemFileHandle getFileSystemFile(const QString fileName);
42
43private:
44 QHash<QString, qstdweb::File> m_files;
45 QHash<QString, qstdweb::FileSystemFileHandle> m_fileSystemFiles;
46};
47
49{
50public:
51 explicit QWasmFileEngine(const QString &fileName, qstdweb::File file);
52 explicit QWasmFileEngine(const QString &fileName, qstdweb::FileSystemFileHandle file);
54
55 virtual bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions) override;
56 virtual bool close() override;
57 virtual bool flush() override;
58 virtual bool syncToDisk() override;
59 virtual qint64 size() const override;
60 virtual qint64 pos() const override;
61 virtual bool seek(qint64 pos) override;
62 virtual bool isSequential() const override;
63 virtual bool remove() override;
64 virtual bool copy(const QString &newName) override;
65 virtual bool rename(const QString &newName) override;
66 virtual bool renameOverwrite(const QString &newName) override;
67 virtual bool link(const QString &newName) override;
68 virtual bool mkdir(const QString &dirName, bool createParentDirectories,
69 std::optional<QFile::Permissions> permissions = std::nullopt) const override;
70 virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const override;
71 virtual bool setSize(qint64 size) override;
72 virtual bool caseSensitive() const override;
73 virtual bool isRelativePath() const override;
74 virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const override;
75 virtual bool setPermissions(uint perms) override;
76 virtual QByteArray id() const override;
77 virtual QString fileName(FileName file = DefaultName) const override;
78 virtual uint ownerId(FileOwner) const override;
79 virtual QString owner(FileOwner) const override;
80 virtual bool setFileTime(const QDateTime &newDate, QFile::FileTime time) override;
81 virtual QDateTime fileTime(QFile::FileTime time) const override;
82 virtual void setFileName(const QString &file) override;
83 virtual int handle() const override;
84 virtual TriStateResult cloneTo(QAbstractFileEngine *target) override;
85 virtual IteratorUniquePtr beginEntryList(const QString &path, QDirListing::IteratorFlags filters,
86 const QStringList &filterNames) override;
87 virtual qint64 read(char *data, qint64 maxlen) override;
88 virtual qint64 readLine(char *data, qint64 maxlen) override;
89 virtual qint64 write(const char *data, qint64 len) override;
90 virtual bool extension(Extension extension, const ExtensionOption *option = nullptr,
91 ExtensionReturn *output = nullptr) override;
92 virtual bool supportsExtension(Extension extension) const override;
93
94private:
95 QString m_fileName;
96 QIODevice::OpenMode m_openMode = QIODevice::NotOpen;
97 std::unique_ptr<qstdweb::BlobIODevice> m_blobDevice;
98 std::unique_ptr<qstdweb::FileSystemFileIODevice> m_fileDevice;
99};
100
101QT_END_NAMESPACE
102#endif // QWASMFILEENGINEHANDLER_H
qstdweb::FileSystemFileHandle getFileSystemFile(const QString fileName)
static QString nativeFileName(const QString &wasmFileName)
static QString makeWasmFileName(const QString &fileName)
virtual ~QWasmFileEngineHandler() override
static QString addFile(qstdweb::File file)
static void removeFile(const QString fileName)
virtual std::unique_ptr< QAbstractFileEngine > create(const QString &fileName) const override
If this file handler can handle fileName, this method creates a file engine and returns it wrapped in...
static bool isWasmFileName(const QString &fileName)
qstdweb::File getFile(const QString fileName)
The QWasmFileEngine class provides a QAbstractFileEngine for files that has the prefix ':weblocalfile...
virtual bool link(const QString &newName) override
Creates a link from the file currently specified by fileName() to newName.
virtual bool flush() override
Flushes the open file, returning true if successful; otherwise returns false.
virtual qint64 read(char *data, qint64 maxlen) override
Reads a number of characters from the file into data.
virtual void setFileName(const QString &file) override
Sets the file engine's file name to file.
virtual bool rmdir(const QString &dirName, bool recurseParentDirectories) const override
Requests that the directory dirName is deleted from the file system.
virtual bool setSize(qint64 size) override
Requests that the file be set to size size.
virtual bool copy(const QString &newName) override
Copies the contents of this file to a file with the name newName.
virtual uint ownerId(FileOwner) const override
If owner is OwnerUser return the ID of the user who owns the file.
virtual bool caseSensitive() const override
Should return true if the underlying file system is case-sensitive; otherwise return false.
virtual QString fileName(FileName file=DefaultName) const override
Return the file engine's current file name in the format specified by file.
virtual qint64 pos() const override
Returns the current file position.
virtual bool supportsExtension(Extension extension) const override
virtual bool extension(Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr) override
virtual bool close() override
Closes the file, returning true if successful; otherwise returns false.
virtual bool isSequential() const override
Returns true if the file is a sequential access device; returns false if the file is a direct access ...
virtual bool syncToDisk() override
virtual bool seek(qint64 pos) override
Sets the file position to the given offset.
virtual qint64 write(const char *data, qint64 len) override
Writes len bytes from data to the file.
virtual TriStateResult cloneTo(QAbstractFileEngine *target) override
virtual bool rename(const QString &newName) override
Requests that the file be renamed to newName in the file system.
virtual QByteArray id() const override
virtual QString owner(FileOwner) const override
If owner is OwnerUser return the name of the user who owns the file.
virtual qint64 readLine(char *data, qint64 maxlen) override
This function reads one line, terminated by a '\n' character, from the file info data.
virtual bool setPermissions(uint perms) override
Requests that the file's permissions be set to perms.
virtual int handle() const override
Returns the native file handle for this file engine.
virtual bool remove() override
Requests that the file is deleted from the file system.
virtual IteratorUniquePtr beginEntryList(const QString &path, QDirListing::IteratorFlags filters, const QStringList &filterNames) override
Returns a QAbstractFileEngine::IteratorUniquePtr, that can be used to iterate over the entries in pat...
virtual FileFlags fileFlags(FileFlags type=FileInfoAll) const override
This function should return the set of OR'd flags that are true for the file engine's file,...
virtual bool open(QIODevice::OpenMode openMode, std::optional< QFile::Permissions > permissions) override
Opens the file in the specified mode.
virtual bool mkdir(const QString &dirName, bool createParentDirectories, std::optional< QFile::Permissions > permissions=std::nullopt) const override
Requests that the directory dirName be created with the specified permissions.
virtual qint64 size() const override
Returns the size of the file.
QWasmFileEngine(const QString &fileName, qstdweb::File file)
virtual bool renameOverwrite(const QString &newName) override
virtual bool isRelativePath() const override
Return true if the file referred to by this file engine has a relative path; otherwise return false.
virtual QDateTime fileTime(QFile::FileTime time) const override
If time is BirthTime, return when the file was born (created).
virtual bool setFileTime(const QDateTime &newDate, QFile::FileTime time) override
Combined button and popup list for selecting options.
static constexpr QLatin1StringView wasmlocalfileScheme