Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfsfileengine.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qfsfileengine_p.h"
8#include "qdatetime.h"
9#include "qset.h"
10#include <QtCore/qdebug.h>
11
12#ifndef QT_NO_FSFILEENGINE
13
14#include <errno.h>
15#if defined(Q_OS_UNIX)
16#include "private/qcore_unix_p.h"
17#endif
18#include <stdio.h>
19#include <stdlib.h>
20#if defined(Q_OS_DARWIN)
21# include <private/qcore_mac_p.h>
22#endif
23
25
26using namespace Qt::StringLiterals;
27
28#ifdef Q_OS_WIN
29# ifndef S_ISREG
30# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
31# endif
32# ifndef S_ISCHR
33# define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
34# endif
35# ifndef S_ISFIFO
36# define S_ISFIFO(x) false
37# endif
38# ifndef S_ISSOCK
39# define S_ISSOCK(x) false
40# endif
41# ifndef INVALID_FILE_ATTRIBUTES
42# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
43# endif
44#endif
45
46#ifdef Q_OS_WIN
47// on Windows, read() and write() use int and unsigned int
48typedef int SignedIOType;
49typedef unsigned int UnsignedIOType;
50#else
51typedef ssize_t SignedIOType;
52typedef size_t UnsignedIOType;
53static_assert(sizeof(SignedIOType) == sizeof(UnsignedIOType),
54 "Unsupported: read/write return a type with different size as the len parameter");
55#endif
56
78//**************** QFSFileEnginePrivate
83
88{
89 is_sequential = 0;
90 tried_stat = 0;
91 need_lstat = 1;
92 is_link = 0;
94 fd = -1;
95 fh = nullptr;
97 lastFlushFailed = false;
98 closeFileHandle = false;
99#ifdef Q_OS_WIN
100 fileAttrib = INVALID_FILE_ATTRIBUTES;
101 fileHandle = INVALID_HANDLE_VALUE;
102 mapHandle = NULL;
103 cachedFd = -1;
104#endif
105}
106
116
123
131
135ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode openMode)
136{
138 result.ok = false;
139 if ((openMode & QFile::NewOnly) && (openMode & QFile::ExistingOnly)) {
140 qWarning("NewOnly and ExistingOnly are mutually exclusive");
141 result.error = "NewOnly and ExistingOnly are mutually exclusive"_L1;
142 return result;
143 }
144
145 if ((openMode & QFile::ExistingOnly) && !(openMode & (QFile::ReadOnly | QFile::WriteOnly))) {
146 qWarning("ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite");
147 result.error =
148 "ExistingOnly must be specified alongside ReadOnly, WriteOnly, or ReadWrite"_L1;
149 return result;
150 }
151
152 // Either Append or NewOnly implies WriteOnly
153 if (openMode & (QFile::Append | QFile::NewOnly))
154 openMode |= QFile::WriteOnly;
155
156 // WriteOnly implies Truncate when ReadOnly, Append, and NewOnly are not set.
157 if ((openMode & QFile::WriteOnly) && !(openMode & (QFile::ReadOnly | QFile::Append | QFile::NewOnly)))
158 openMode |= QFile::Truncate;
159
160 result.ok = true;
161 result.openMode = openMode;
162 return result;
163}
164
169{
170 Q_D(QFSFileEngine);
171 if (d->closeFileHandle) {
172 if (d->fh) {
173 fclose(d->fh);
174 } else if (d->fd != -1) {
175 QT_CLOSE(d->fd);
176 }
177 }
178 d->unmapAll();
179}
180
185{
186 Q_D(QFSFileEngine);
187 d->init();
188 d->fileEntry = QFileSystemEntry(file);
189}
190
194bool QFSFileEngine::open(QIODevice::OpenMode openMode,
195 std::optional<QFile::Permissions> permissions)
196{
197 Q_ASSERT_X(openMode & QIODevice::Unbuffered, "QFSFileEngine::open",
198 "QFSFileEngine no longer supports buffered mode; upper layer must buffer");
199
200 Q_D(QFSFileEngine);
201 if (d->fileEntry.isEmpty()) {
202 qWarning("QFSFileEngine::open: No file name specified");
203 setError(QFile::OpenError, "No file name specified"_L1);
204 return false;
205 }
206
208 if (!res.ok) {
210 return false;
211 }
212
213 d->openMode = res.openMode;
214 d->lastFlushFailed = false;
215 d->tried_stat = 0;
216 d->fh = nullptr;
217 d->fd = -1;
218
219 return d->nativeOpen(d->openMode, permissions);
220}
221
226bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh)
227{
228 return open(openMode, fh, QFile::DontCloseHandle);
229}
230
231bool QFSFileEngine::open(QIODevice::OpenMode openMode, FILE *fh, QFile::FileHandleFlags handleFlags)
232{
233 Q_ASSERT_X(openMode & QIODevice::Unbuffered, "QFSFileEngine::open",
234 "QFSFileEngine no longer supports buffered mode; upper layer must buffer");
235
236 Q_D(QFSFileEngine);
237
239 if (!res.ok) {
241 return false;
242 }
243
244 d->openMode = res.openMode;
245 d->lastFlushFailed = false;
246 d->closeFileHandle = handleFlags.testAnyFlag(QFile::AutoCloseHandle);
247 d->fileEntry.clear();
248 d->tried_stat = 0;
249 d->fd = -1;
250
251 return d->openFh(d->openMode, fh);
252}
253
257bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
258{
259 Q_ASSERT_X(openMode & QIODevice::Unbuffered, "QFSFileEngine::open",
260 "QFSFileEngine no longer supports buffered mode; upper layer must buffer");
261
262 Q_Q(QFSFileEngine);
263 this->fh = fh;
264 fd = -1;
265
266 // Seek to the end when in Append mode.
268 int ret;
269 do {
270 ret = QT_FSEEK(fh, 0, SEEK_END);
271 } while (ret != 0 && errno == EINTR);
272
273 if (ret != 0) {
274 q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
276
277 this->openMode = QIODevice::NotOpen;
278 this->fh = nullptr;
279
280 return false;
281 }
282 }
283
284 return true;
285}
286
291bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd)
292{
293 return open(openMode, fd, QFile::DontCloseHandle);
294}
295
296bool QFSFileEngine::open(QIODevice::OpenMode openMode, int fd, QFile::FileHandleFlags handleFlags)
297{
298 Q_D(QFSFileEngine);
299
301 if (!res.ok) {
303 return false;
304 }
305
306 d->openMode = res.openMode;
307 d->lastFlushFailed = false;
308 d->closeFileHandle = handleFlags.testAnyFlag(QFile::AutoCloseHandle);
309 d->fileEntry.clear();
310 d->fh = nullptr;
311 d->fd = -1;
312 d->tried_stat = 0;
313
314 return d->openFd(d->openMode, fd);
315}
316
317
322bool QFSFileEnginePrivate::openFd(QIODevice::OpenMode openMode, int fd)
323{
324 Q_Q(QFSFileEngine);
325 this->fd = fd;
326 fh = nullptr;
327
328 // Seek to the end when in Append mode.
329 if (openMode & QFile::Append) {
330 QT_OFF_T ret;
331 do {
332 ret = QT_LSEEK(fd, 0, SEEK_END);
333 } while (ret == -1 && errno == EINTR);
334
335 if (ret == -1) {
336 q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
338
339 this->openMode = QIODevice::NotOpen;
340 this->fd = -1;
341
342 return false;
343 }
344 }
345
346 return true;
347}
348
353{
354 Q_D(QFSFileEngine);
355 d->openMode = QIODevice::NotOpen;
356 return d->nativeClose();
357}
358
363{
364 Q_Q(QFSFileEngine);
365 if (fd == -1 && !fh)
366 return false;
367
368 // Flush the file if it's buffered, and if the last flush didn't fail.
369 bool flushed = !fh || (!lastFlushFailed && q->flush());
370 bool closed = true;
371 tried_stat = 0;
372
373 // Close the file if we created the handle.
374 if (closeFileHandle) {
375 int ret;
376
377 if (fh) {
378 // Close buffered file.
379 ret = fclose(fh);
380 } else {
381 // Close unbuffered file.
382 ret = QT_CLOSE(fd);
383 }
384
385 // We must reset these guys regardless; calling close again after a
386 // failed close causes crashes on some systems.
387 fh = nullptr;
388 fd = -1;
389 closed = (ret == 0);
390 }
391
392 // Report errors.
393 if (!flushed || !closed) {
394 if (flushed) {
395 // If not flushed, we want the flush error to fall through.
397 }
398 return false;
399 }
400
401 return true;
402}
403
408{
409 Q_D(QFSFileEngine);
410 if ((d->openMode & QIODevice::WriteOnly) == 0) {
411 // Nothing in the write buffers, so flush succeeds in doing
412 // nothing.
413 return true;
414 }
415 return d->nativeFlush();
416}
417
422{
423 Q_D(QFSFileEngine);
424 if ((d->openMode & QIODevice::WriteOnly) == 0)
425 return true;
426 return d->nativeSyncToDisk();
427}
428
433{
434 Q_Q(QFSFileEngine);
435
436 // Never try to flush again if the last flush failed. Otherwise you can
437 // get crashes on some systems (AIX).
438 if (lastFlushFailed)
439 return false;
440
441 int ret = fflush(fh);
442
443 lastFlushFailed = (ret != 0);
445
446 if (ret != 0) {
447 q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError,
449 return false;
450 }
451 return true;
452}
453
458{
459 Q_D(const QFSFileEngine);
460 return d->nativeSize();
461}
462
467{
468 if (!maps.isEmpty()) {
469 const QList<uchar*> keys = maps.keys(); // Make a copy since unmap() modifies the map.
470 for (int i = 0; i < keys.size(); ++i)
471 unmap(keys.at(i));
472 }
473}
474
475#ifndef Q_OS_WIN
480{
481 Q_Q(const QFSFileEngine);
482 const_cast<QFSFileEngine *>(q)->flush();
483
484 tried_stat = 0;
487 return 0;
488 return metaData.size();
489}
490#endif
491
496{
497 Q_D(const QFSFileEngine);
498 return d->nativePos();
499}
500
505{
506 if (fh)
507 return qint64(QT_FTELL(fh));
508 return QT_LSEEK(fd, 0, SEEK_CUR);
509}
510
515{
516 Q_D(QFSFileEngine);
517 return d->nativeSeek(pos);
518}
519
524{
525 Q_D(const QFSFileEngine);
526
528 // always refresh for the access time
529 d->metaData.clearFlags(QFileSystemMetaData::AccessTime);
530 }
531
532 if (d->doStat(QFileSystemMetaData::Times))
533 return d->metaData.fileTime(time);
534
535 return QDateTime();
536}
537
538
543{
544 Q_Q(QFSFileEngine);
545
546 // On Windows' stdlib implementation, the results of calling fread and
547 // fwrite are undefined if not called either in sequence, or if preceded
548 // with a call to fflush().
550 return false;
551
552 if (pos < 0 || pos != qint64(QT_OFF_T(pos)))
553 return false;
554
555 if (fh) {
556 // Buffered stdlib mode.
557 int ret;
558 do {
559 ret = QT_FSEEK(fh, QT_OFF_T(pos), SEEK_SET);
560 } while (ret != 0 && errno == EINTR);
561
562 if (ret != 0) {
563 q->setError(QFile::ReadError, QSystemError::stdString(errno));
564 return false;
565 }
566 } else {
567 // Unbuffered stdio mode.
568 if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
570 qWarning("QFile::at: Cannot set file position %lld", pos);
571 return false;
572 }
573 }
574 return true;
575}
576
581{
582 Q_D(const QFSFileEngine);
583 return d->nativeHandle();
584}
585
590{
591 Q_D(QFSFileEngine);
592
593 // On Windows' stdlib implementation, the results of calling fread and
594 // fwrite are undefined if not called either in sequence, or if preceded
595 // with a call to fflush().
596 if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) {
597 flush();
598 d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand;
599 }
600
601 return d->nativeRead(data, maxlen);
602}
603
608{
609 Q_Q(QFSFileEngine);
610
611 if (len < 0 || len != qint64(size_t(len))) {
612 q->setError(QFile::ReadError, QSystemError::stdString(EINVAL));
613 return -1;
614 }
615
616 qint64 readBytes = 0;
617 bool eof = false;
618
619 if (fh) {
620 // Buffered stdlib mode.
621
622 size_t result;
623 do {
624 result = fread(data + readBytes, 1, size_t(len - readBytes), fh);
625 eof = feof(fh); // Doesn't change errno
626 if (eof && result == 0) {
627 // On OS X, this is needed, e.g., if a file was written to
628 // through another stream since our last read. See test
629 // tst_QFile::appendAndRead
630 QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream.
631 break;
632 }
633 readBytes += result;
634 } while (!eof && (result == 0 ? errno == EINTR : readBytes < len));
635
636 } else if (fd != -1) {
637 // Unbuffered stdio mode.
638
640 do {
641 // calculate the chunk size
642 // on Windows or 32-bit no-largefile Unix, we'll need to read in chunks
643 // we limit to the size of the signed type, otherwise we could get a negative number as a result
644 quint64 wantedBytes = quint64(len) - quint64(readBytes);
645 UnsignedIOType chunkSize = std::numeric_limits<SignedIOType>::max();
646 if (chunkSize > wantedBytes)
647 chunkSize = wantedBytes;
648 result = QT_READ(fd, data + readBytes, chunkSize);
649 } while (result > 0 && (readBytes += result) < len);
650
651 // QT_READ (::read()) returns 0 to indicate end-of-file
652 eof = result == 0;
653 }
654
655 if (!eof && readBytes == 0) {
656 readBytes = -1;
657 q->setError(QFile::ReadError, QSystemError::stdString(errno));
658 }
659
660 return readBytes;
661}
662
667{
668 Q_D(QFSFileEngine);
669
670 // On Windows' stdlib implementation, the results of calling fread and
671 // fwrite are undefined if not called either in sequence, or if preceded
672 // with a call to fflush().
673 if (d->lastIOCommand != QFSFileEnginePrivate::IOReadCommand) {
674 flush();
675 d->lastIOCommand = QFSFileEnginePrivate::IOReadCommand;
676 }
677
678 return d->nativeReadLine(data, maxlen);
679}
680
685{
686 Q_Q(QFSFileEngine);
687 if (!fh)
688 return q->QAbstractFileEngine::readLine(data, maxlen);
689
690 QT_OFF_T oldPos = 0;
691#ifdef Q_OS_WIN
692 bool seq = q->isSequential();
693 if (!seq)
694#endif
695 oldPos = QT_FTELL(fh);
696
697 // QIODevice::readLine() passes maxlen - 1 to QFile::readLineData()
698 // because it has made space for the '\0' at the end of data. But fgets
699 // does the same, so we'd get two '\0' at the end - passing maxlen + 1
700 // solves this.
701 if (!fgets(data, int(maxlen + 1), fh)) {
702 if (!feof(fh)) // Doesn't change errno
703 q->setError(QFile::ReadError, QSystemError::stdString(errno));
704 return -1; // error
705 }
706
707#ifdef Q_OS_WIN
708 if (seq)
709 return qstrlen(data);
710#endif
711
712 qint64 lineLength = QT_FTELL(fh) - oldPos;
713 return lineLength > 0 ? lineLength : qstrlen(data);
714}
715
720{
721 Q_D(QFSFileEngine);
722 d->metaData.clearFlags(QFileSystemMetaData::Times);
723
724 // On Windows' stdlib implementation, the results of calling fread and
725 // fwrite are undefined if not called either in sequence, or if preceded
726 // with a call to fflush().
727 if (d->lastIOCommand != QFSFileEnginePrivate::IOWriteCommand) {
728 flush();
730 }
731
732 return d->nativeWrite(data, len);
733}
734
739{
740 Q_Q(QFSFileEngine);
741
742 if (len < 0 || len != qint64(size_t(len))) {
743 q->setError(QFile::WriteError, QSystemError::stdString(EINVAL));
744 return -1;
745 }
746
747 qint64 writtenBytes = 0;
748
749 if (len) { // avoid passing nullptr to fwrite() or QT_WRITE() (UB)
750
751 if (fh) {
752 // Buffered stdlib mode.
753
754 size_t result;
755 do {
756 result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh);
757 writtenBytes += result;
758 } while (result == 0 ? errno == EINTR : writtenBytes < len);
759
760 } else if (fd != -1) {
761 // Unbuffered stdio mode.
762
764 do {
765 // calculate the chunk size
766 // on Windows or 32-bit no-largefile Unix, we'll need to read in chunks
767 // we limit to the size of the signed type, otherwise we could get a negative number as a result
768 quint64 wantedBytes = quint64(len) - quint64(writtenBytes);
769 UnsignedIOType chunkSize = std::numeric_limits<SignedIOType>::max();
770 if (chunkSize > wantedBytes)
771 chunkSize = wantedBytes;
772 result = QT_WRITE(fd, data + writtenBytes, chunkSize);
773 } while (result > 0 && (writtenBytes += result) < len);
774 }
775
776 }
777
778 if (len && writtenBytes == 0) {
779 writtenBytes = -1;
780 q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError,
782 } else {
783 // reset the cached size, if any
785 }
786
787 return writtenBytes;
788}
789
790#ifndef QT_NO_FILESYSTEMITERATOR
796 const QStringList &filterNames)
797{
798 return std::make_unique<QFSFileEngineIterator>(path, filters, filterNames);
799}
800
801#endif // QT_NO_FILESYSTEMITERATOR
802
806QStringList QFSFileEngine::entryList(QDir::Filters filters, const QStringList &filterNames) const
807{
808 return QAbstractFileEngine::entryList(filters, filterNames);
809}
810
815{
816 Q_D(const QFSFileEngine);
817 if (d->is_sequential == 0)
818 d->is_sequential = d->nativeIsSequential() ? 1 : 2;
819 return d->is_sequential == 1;
820}
821
825#ifdef Q_OS_UNIX
827{
829 return metaData.isSequential();
830 return true;
831}
832#endif
833
838{
839 Q_D(QFSFileEngine);
840 if (extension == AtEndExtension && d->fh && isSequential())
841 return feof(d->fh);
842
843 if (extension == MapExtension) {
844 const MapExtensionOption *options = (const MapExtensionOption*)(option);
845 MapExtensionReturn *returnValue = static_cast<MapExtensionReturn*>(output);
846 returnValue->address = d->map(options->offset, options->size, options->flags);
847 return (returnValue->address != nullptr);
848 }
849 if (extension == UnMapExtension) {
850 const UnMapExtensionOption *options = (const UnMapExtensionOption*)option;
851 return d->unmap(options->address);
852 }
853
854 return false;
855}
856
861{
862 Q_D(const QFSFileEngine);
863 if (extension == AtEndExtension && d->fh && isSequential())
864 return true;
865 if (extension == FastReadLineExtension && d->fh)
866 return true;
867 if (extension == FastReadLineExtension && d->fd != -1 && isSequential())
868 return true;
870 return true;
871 return false;
872}
873
916
926
935
969bool QFSFileEngine::copy(const QString &copyName)
970{
971 Q_D(QFSFileEngine);
973 bool ret = QFileSystemEngine::copyFile(d->fileEntry, QFileSystemEntry(copyName), error);
974 if (!ret)
975 setError(QFile::CopyError, error.toString());
976 return ret;
977}
978
983{
984 Q_D(QFSFileEngine);
986 bool ret = QFileSystemEngine::removeFile(d->fileEntry, error);
987 d->metaData.clear();
988 if (!ret)
989 setError(QFile::RemoveError, error.toString());
990 return ret;
991}
992
993/*
994 An alternative to setFileName() when you have already constructed
995 a QFileSystemEntry.
996*/
998{
999 Q_D(QFSFileEngine);
1000 d->init();
1001 d->fileEntry = std::move(entry);
1002}
1003
1004bool QFSFileEngine::rename_helper(const QString &newName, RenameMode mode)
1005{
1006 Q_D(QFSFileEngine);
1007
1008 auto func = mode == Rename ? QFileSystemEngine::renameFile
1011 auto newEntry = QFileSystemEntry(newName);
1012 const bool ret = func(d->fileEntry, newEntry, error);
1013 if (!ret) {
1014 setError(QFile::RenameError, error.toString());
1015 return false;
1016 }
1017 setFileEntry(std::move(newEntry));
1018 return true;
1019}
1020
1024bool QFSFileEngine::mkdir(const QString &name, bool createParentDirectories,
1025 std::optional<QFile::Permissions> permissions) const
1026{
1027 return QFileSystemEngine::createDirectory(QFileSystemEntry(name), createParentDirectories,
1028 permissions);
1029}
1030
1034bool QFSFileEngine::rmdir(const QString &name, bool recurseParentDirectories) const
1035{
1036 return QFileSystemEngine::removeDirectory(QFileSystemEntry(name), recurseParentDirectories);
1037}
1038
1039
1050
1064
1065#endif // QT_NO_FSFILEENGINE
\inmodule QtCore \reentrant
void setError(QFile::FileError error, const QString &str)
Sets the error type to error, and the error string to errorString.
virtual QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const
Requests that a list of all the files matching the filters list based on the filterNames in the file ...
std::unique_ptr< Iterator > IteratorUniquePtr
QFile::FileError error() const
Returns the QFile::FileError that resulted from the last failed operation.
\inmodule QtCore\reentrant
Definition qdatetime.h:283
qint64 readFdFh(char *data, qint64 maxlen)
bool openFd(QIODevice::OpenMode flags, int fd)
Opens the file descriptor fd to the file engine, using the open mode flags.
QHash< uchar *, StartAndLength > maps
qint64 writeFdFh(const char *data, qint64 len)
QIODevice::OpenMode openMode
qint64 sizeFdFh() const
bool doStat(QFileSystemMetaData::MetaDataFlags flags=QFileSystemMetaData::PosixStatFlags) const
QFileSystemMetaData metaData
bool isSequentialFdFh() const
qint64 readLineFdFh(char *data, qint64 maxlen)
bool openFh(QIODevice::OpenMode flags, FILE *fh)
Opens the file handle fh using the open mode flags.
LastIOCommand lastIOCommand
\inmodule QtCore
qint64 read(char *data, qint64 maxlen) override
\reimp
qint64 write(const char *data, qint64 len) override
\reimp
bool rmdir(const QString &dirName, bool recurseParentDirectories) const override
\reimp
static QString tempPath()
Returns the temporary path (i.e., a path in which it is safe to store temporary files).
qint64 pos() const override
\reimp
bool close() override
\reimp
bool syncToDisk() override
\reimp
QFSFileEngine()
Constructs a QFSFileEngine.
qint64 size() const override
\reimp
static QString rootPath()
Returns the root path.
QDateTime fileTime(QFile::FileTime time) const override
\reimp
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override
bool isSequential() const override
\reimp
bool open(QIODevice::OpenMode openMode, std::optional< QFile::Permissions > permissions) override
\reimp
void setFileName(const QString &file) override
\reimp
bool seek(qint64) override
\reimp
static bool setCurrentPath(const QString &path)
Sets the current path (e.g., for QDir), to path.
bool mkdir(const QString &dirName, bool createParentDirectories, std::optional< QFile::Permissions > permissions) const override
\reimp
bool copy(const QString &newName) override
For Windows or Apple platforms, copy the file to file copyName.
bool supportsExtension(Extension extension) const override
\reimp
int handle() const override
\reimp
bool extension(Extension extension, const ExtensionOption *option=nullptr, ExtensionReturn *output=nullptr) override
\reimp
qint64 readLine(char *data, qint64 maxlen) override
\reimp
void setFileEntry(QFileSystemEntry &&entry)
IteratorUniquePtr beginEntryList(const QString &path, QDir::Filters filters, const QStringList &filterNames) override
static QString homePath()
Returns the home path of the current user.
bool remove() override
\reimp
~QFSFileEngine()
Destructs the QFSFileEngine.
bool flush() override
\reimp
static bool setCurrentPath(const QFileSystemEntry &entry)
static bool copyFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
static bool renameOverwriteFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
static bool createDirectory(const QFileSystemEntry &entry, bool createParents, std::optional< QFile::Permissions > permissions=std::nullopt)
static bool renameFile(const QFileSystemEntry &source, const QFileSystemEntry &target, QSystemError &error)
static bool removeFile(const QFileSystemEntry &entry, QSystemError &error)
static bool removeDirectory(const QFileSystemEntry &entry, bool removeEmptyParents)
void clearFlags(MetaDataFlags flags=AllMetaDataFlags)
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static Q_CORE_EXPORT QString stdString(int errorCode=-1)
void extension()
[6]
Definition dialogs.cpp:230
Combined button and popup list for selecting options.
size_t qstrlen(const char *str)
#define QT_READ
#define QT_CLOSE
#define QT_WRITE
#define INVALID_FILE_ATTRIBUTES
size_t UnsignedIOType
ssize_t SignedIOType
ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode openMode)
Q_CORE_EXPORT ProcessOpenModeResult processOpenModeFlags(QIODevice::OpenMode mode)
#define qWarning
Definition qlogging.h:166
return ret
GLenum mode
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint64 GLenum GLint fd
GLuint name
GLenum func
Definition qopenglext.h:663
GLuint res
GLuint entry
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLuint GLenum option
GLenum GLsizei len
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
unsigned long long quint64
Definition qtypes.h:61
long long qint64
Definition qtypes.h:60
QT_BEGIN_NAMESPACE typedef uchar * output
QFile file
[0]
QStringList keys
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]