4#include "qplatformdefs.h"
10#define tr(X) QString::fromLatin1(X)
15#ifndef QFILE_WRITEBUFFER_SIZE
16#define QFILE_WRITEBUFFER_SIZE 16384
31 fileEngine = std::make_unique<QFSFileEngine>();
252 return d->fileEngine &&
d->fileEngine->isSequential();
270 if (!
isOpen() || !
d->fileEngine)
273 return d->fileEngine->handle();
292 if (!
d->fileEngine) {
293 qWarning(
"QFileDevice::flush: No file engine. Is IODevice open?");
297 if (!
d->writeBuffer.isEmpty()) {
299 qint64 written =
d->fileEngine->write(
d->writeBuffer.readPointer(),
size);
301 d->writeBuffer.free(written);
302 if (written !=
size) {
306 d->setError(err,
d->fileEngine->errorString());
311 if (!
d->fileEngine->flush()) {
315 d->setError(err,
d->fileEngine->errorString());
331 bool flushed =
flush();
335 d->lastWasWrite =
false;
336 d->writeBuffer.clear();
342 if (
d->fileEngine->close() && flushed)
345 d->setError(
d->fileEngine->error(),
d->fileEngine->errorString());
370 if (!
d->isBufferEmpty())
376 if (!
d->ensureFlushed())
383 return d->fileEngine->atEnd();
388 if (
pos() <
d->cachedSize)
414 qWarning(
"QFileDevice::seek: IODevice is not open");
418 if (!
d->ensureFlushed())
425 d->setError(err,
d->fileEngine->errorString());
438 if (!
d->ensureFlushed())
443 read =
d->fileEngine->readLine(
data, maxlen);
467 if (!
d->ensureFlushed())
475 d->setError(err,
d->fileEngine->errorString());
508 qWarning(
"QIODevice::putChar: Closed device");
510 qWarning(
"QIODevice::putChar: ReadOnly device");
550 d->lastWasWrite =
true;
554 if (buffered && (
d->writeBuffer.size() +
len) >
d->writeBufferChunkSize) {
561 if (!buffered ||
len >
d->writeBufferChunkSize) {
567 d->setError(err,
d->fileEngine->errorString());
613 if (!
d->ensureFlushed())
615 d->cachedSize =
d->engine()->size();
616 return d->cachedSize;
632 if (!
d->ensureFlushed())
635 if (
isOpen() &&
d->fileEngine->pos() > sz)
637 if (
d->fileEngine->setSize(sz)) {
657 return QFile::Permissions::fromInt(perms.toInt());
722 d->setError(
d->fileEngine->error(),
d->fileEngine->errorString());
741 bool success =
d->fileEngine->unmap(
address);
743 d->setError(
d->fileEngine->error(),
d->fileEngine->errorString());
746 d->setError(
PermissionsError,
tr(
"No file engine available or engine does not support UnMapExtension"));
779 return d->engine()->fileTime(
time);
802 if (!
d->fileEngine->setFileTime(newDate,
fileTime)) {
803 d->setError(
d->fileEngine->error(),
d->fileEngine->errorString());
814#include "moc_qfiledevice.cpp"
\inmodule QtCore \reentrant
\inmodule QtCore\reentrant
bool putCharHelper(char c) override
std::unique_ptr< QAbstractFileEngine > fileEngine
virtual QAbstractFileEngine * engine() const
void setError(QFileDevice::FileError err)
QFileDevice::FileError error
qint64 readLineData(char *data, qint64 maxlen) override
\reimp
qint64 readData(char *data, qint64 maxlen) override
\reimp
bool flush()
Flushes any buffered data to the file.
~QFileDevice()
Destroys the file device, closing it if necessary.
QDateTime fileTime(QFileDevice::FileTime time) const
qint64 pos() const override
\reimp
bool seek(qint64 offset) override
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 size() const override
Returns the size of the file.
void unsetError()
Sets the file's error to QFileDevice::NoError.
virtual bool resize(qint64 sz)
Sets the file size (in bytes) sz.
qint64 writeData(const char *data, qint64 len) override
\reimp
uchar * map(qint64 offset, qint64 size, MemoryMapFlags flags=NoOptions)
Maps size bytes of the file into memory starting at offset.
int handle() const
Returns the file handle of the file.
QFileDevice()
\macro QT_USE_NODISCARD_FILE_OPEN \macro QT_NO_USE_NODISCARD_FILE_OPEN
bool setFileTime(const QDateTime &newDate, QFileDevice::FileTime fileTime)
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
FileError error() const
Returns the file error status.
bool isSequential() const override
Returns true if the file can only be manipulated sequentially; otherwise returns false.
virtual QString fileName() const
Returns the name of the file.
FileError
This enum describes the errors that may be returned by the error() function.
virtual bool setPermissions(Permissions permissionSpec)
Sets the permissions for the file to the permissions specified.
bool unmap(uchar *address)
Unmaps the memory address.
void close() override
Calls QFileDevice::flush() and closes the file.
virtual Permissions permissions() const
Returns the complete OR-ed together combination of QFile::Permission for the file.
QIODevice::OpenMode openMode
bool isSequential() const
virtual bool putCharHelper(char c)
\inmodule QtCore \reentrant
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
bool isOpen() const
Returns true if the device is open; otherwise returns false.
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual qint64 readLineData(char *data, qint64 maxlen)
Reads up to maxSize characters into data and returns the number of characters read.
virtual void close()
First emits aboutToClose(), then closes the device and sets its OpenMode to NotOpen.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success,...
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define QFILE_WRITEBUFFER_SIZE
Q_DECL_COLD_FUNCTION Q_CORE_EXPORT QString qt_error_string(int errorCode=-1)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLuint GLuint64EXT address