47 Q_DECLARE_PRIVATE(QFSFileEngine)
50 explicit QFSFileEngine(
const QString &file);
53 bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions) override;
54 bool close() override;
55 bool flush() override;
56 bool syncToDisk() override;
57 qint64 size()
const override;
58 qint64 pos()
const override;
59 bool seek(qint64) override;
60 bool isSequential()
const override;
61 bool remove() override;
62 bool copy(
const QString &newName) override;
64 bool rename(
const QString &newName) override
65 {
return rename_helper(newName, Rename); }
66 bool renameOverwrite(
const QString &newName) override
67 {
return rename_helper(newName, RenameOverwrite); }
69 bool link(
const QString &newName) override;
70 bool mkdir(
const QString &dirName,
bool createParentDirectories,
71 std::optional<QFile::Permissions> permissions)
const override;
72 bool rmdir(
const QString &dirName,
bool recurseParentDirectories)
const override;
73 bool setSize(qint64 size) override;
74 bool caseSensitive()
const override;
75 bool isRelativePath()
const override;
76 FileFlags fileFlags(FileFlags type)
const override;
77 bool setPermissions(uint perms) override;
78 QByteArray id()
const override;
79 QString fileName(FileName file)
const override;
80 uint ownerId(FileOwner)
const override;
81 QString owner(FileOwner)
const override;
82 bool setFileTime(
const QDateTime &newDate, QFile::FileTime time) override;
83 QDateTime fileTime(QFile::FileTime time)
const override;
84 void setFileName(
const QString &file) override;
85 void setFileEntry(QFileSystemEntry &&entry);
86 int handle()
const override;
88#ifndef QT_NO_FILESYSTEMITERATOR
89 IteratorUniquePtr beginEntryList(
const QString &path, QDirListing::IteratorFlags filters,
90 const QStringList &filterNames) override;
93 qint64 read(
char *data, qint64 maxlen) override;
94 qint64 readLine(
char *data, qint64 maxlen) override;
95 qint64 write(
const char *data, qint64 len) override;
96 TriStateResult cloneTo(QAbstractFileEngine *target) override;
98 virtual bool isUnnamedFile()
const
101 bool extension(Extension extension,
const ExtensionOption *option =
nullptr, ExtensionReturn *output =
nullptr) override;
102 bool supportsExtension(Extension extension)
const override;
105 bool open(QIODevice::OpenMode flags,
int fd, QFile::FileHandleFlags handleFlags);
106 bool open(QIODevice::OpenMode flags, FILE *fh, QFile::FileHandleFlags handleFlags);
107 static bool setCurrentPath(
const QString &path);
108 static QString currentPath(
const QString &path = QString());
109 static QFileInfoList drives();
112 QFSFileEngine(QFSFileEnginePrivate &dd);
115 enum RenameMode :
int { Rename, RenameOverwrite };
116 bool rename_helper(
const QString &newName, RenameMode mode);
121 Q_DECLARE_PUBLIC(QFSFileEngine)
125 static QString longFileName(
const QString &path);
128 QFileSystemEntry fileEntry;
129 QIODevice::OpenMode openMode;
131 bool nativeOpen(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions);
132 bool openFh(QIODevice::OpenMode flags, FILE *fh);
133 bool openFd(QIODevice::OpenMode flags,
int fd);
137 bool nativeSyncToDisk();
139 qint64 nativeSize()
const;
141 qint64 sizeFdFh()
const;
143 qint64 nativePos()
const;
144 qint64 posFdFh()
const;
145 bool nativeSeek(qint64);
146 bool seekFdFh(qint64);
147 qint64 nativeRead(
char *data, qint64 maxlen);
148 qint64 readFdFh(
char *data, qint64 maxlen);
149 qint64 nativeReadLine(
char *data, qint64 maxlen);
150 qint64 readLineFdFh(
char *data, qint64 maxlen);
151 qint64 nativeWrite(
const char *data, qint64 len);
152 qint64 writeFdFh(
const char *data, qint64 len);
153 int nativeHandle()
const;
154 bool nativeIsSequential()
const;
156 bool isSequentialFdFh()
const;
159 bool nativeRenameOverwrite(
const QFileSystemEntry &newEntry);
162 uchar *map(qint64 offset, qint64 size, QFile::MemoryMapFlags flags);
163 bool unmap(uchar *ptr);
166 mutable QFileSystemMetaData metaData;
173 QHash<uchar *, DWORD > maps;
175 mutable int cachedFd;
176 mutable DWORD fileAttrib;
178 struct StartAndLength {
182 QHash<uchar *, StartAndLength> maps;
192 LastIOCommand lastIOCommand;
193 bool lastFlushFailed;
194 bool closeFileHandle;
196 mutable uint is_sequential : 2;
197 mutable uint tried_stat : 1;
198 mutable uint need_lstat : 1;
199 mutable uint is_link : 1;
202 bool doStat(QFileSystemMetaData::MetaDataFlags flags)
const;
204 bool doStat(QFileSystemMetaData::MetaDataFlags flags = QFileSystemMetaData::PosixStatFlags)
const;
206 bool isSymlink()
const;
208#if defined(Q_OS_WIN32)
209 int sysOpen(
const QString &,
int flags);
212 static bool openModeCanCreate(QIODevice::OpenMode openMode)
216 return (openMode & QFile::WriteOnly) && !(openMode & QFile::ExistingOnly);
219 QFSFileEnginePrivate(QAbstractFileEngine *q);
223 QAbstractFileEngine::FileFlags getPermissions(QAbstractFileEngine::FileFlags type)
const;
226 bool nativeOpenImpl(QIODevice::OpenMode openMode, mode_t mode);