CopperSpice API
1.9.2
|
Base class for reading and writing to an open file. More...
Public Typedefs | |
using | FileHandleFlags = QFlags< FileHandleFlag > |
using | Permissions = QFlags< Permission > |
Public Typedefs inherited from QIODevice | |
using | OpenMode = QFlags< OpenModeFlag > |
Public Types | |
enum | FileError |
enum | FileHandleFlag |
enum | MemoryMapFlags |
enum | Permission |
Public Types inherited from QIODevice | |
enum | OpenModeFlag |
Public Methods | |
~QFileDevice () | |
bool | atEnd () const override |
void | close () override |
FileError | error () const |
virtual QString | fileName () const |
bool | flush () |
int | handle () const |
bool | isSequential () const override |
uchar * | map (qint64 offset, qint64 size, MemoryMapFlags flags=NoOptions) |
virtual Permissions | permissions () const |
qint64 | pos () const override |
virtual bool | resize (qint64 size) |
bool | seek (qint64 pos) override |
virtual bool | setPermissions (Permissions permissionSpec) |
qint64 | size () const override |
bool | unmap (uchar *address) |
void | unsetError () |
Public Methods inherited from QIODevice | |
QIODevice () | |
QIODevice (QObject *parent) | |
virtual | ~QIODevice () |
virtual qint64 | bytesAvailable () const |
virtual qint64 | bytesToWrite () const |
virtual bool | canReadLine () const |
QString | errorString () const |
bool | getChar (char *c) |
bool | isOpen () const |
bool | isReadable () const |
bool | isTextModeEnabled () const |
bool | isWritable () const |
virtual bool | open (OpenMode mode) |
OpenMode | openMode () const |
qint64 | peek (char *data, qint64 maxSize) |
QByteArray | peek (qint64 maxSize) |
bool | putChar (char c) |
qint64 | read (char *data, qint64 maxSize) |
QByteArray | read (qint64 maxSize) |
QByteArray | readAll () |
qint64 | readLine (char *data, qint64 maxSize) |
QByteArray | readLine (qint64 maxSize=0) |
virtual bool | reset () |
void | setTextModeEnabled (bool enabled) |
void | ungetChar (char c) |
virtual bool | waitForBytesWritten (int msecs) |
virtual bool | waitForReadyRead (int msecs) |
qint64 | write (const char *data) |
qint64 | write (const char *data, qint64 maxSize) |
qint64 | write (const QByteArray &data) |
Public Methods inherited from QObject | |
QObject (QObject *parent=nullptr) | |
~QObject () | |
bool | blockSignals (bool block) |
const QList< QObject * > & | children () const |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
bool | disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
bool | disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QString > | dynamicPropertyNames () const |
virtual bool | event (QEvent *event) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
template<typename T > | |
T | findChild (const QString &childName=QString ()) const |
template<class T > | |
QList< T > | findChildren (const QRegularExpression ®Exp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
template<class T > | |
QList< T > | findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
bool | inherits (const QString &className) const |
void | installEventFilter (QObject *filterObj) |
bool | isWidgetType () const |
bool | isWindowType () const |
void | killTimer (int id) |
const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const |
QObject * | parent () const |
template<class T = QVariant> | |
T | property (const QString &name) const |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const QString &name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
QThread * | thread () const |
Protected Methods | |
qint64 | readData (char *data, qint64 maxSize) override |
qint64 | readLineData (char *data, qint64 maxSize) override |
qint64 | writeData (const char *data, qint64 maxSize) override |
Protected Methods inherited from QIODevice | |
void | setErrorString (const QString &errorString) |
void | setOpenMode (OpenMode openMode) |
Protected Methods inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signalMethod) const |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signalMethod) const |
bool | isSignalConnected (const QMetaMethod &signalMethod) const |
int | receivers (const QString &signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Additional Inherited Members | |
Public Signals inherited from QIODevice | |
void | aboutToClose () |
void | bytesWritten (qint64 bytes) |
void | readChannelFinished () |
void | readyRead () |
Public Signals inherited from QObject | |
void | destroyed (QObject *obj=nullptr) |
void | objectNameChanged (const QString &objectName) |
Public Slots inherited from QObject | |
void | deleteLater () |
Static Public Methods inherited from QObject | |
static bool | connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ()) |
static bool | connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod) |
static bool | disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...)) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr) |
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T > | |
static bool | disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod) |
static QMetaObject & | staticMetaObject () |
static QString | tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >()) |
Properties inherited from QObject | |
objectName | |
Related Functions inherited from QObject | |
T | qobject_cast (QObject *object) |
QObjectList | |
QFileDevice is a base class for reading and writing to an open file. This class is normally not used directly. Instead use one of its child classes like QFile or QTemporaryFile.
No constructors are provided in this class.
Typedef for QFlags<FileHandleFlag> which contains an OR combination of FileHandleFlag values.
Refer to QFileDevice::FileHandleFlag for the enum documentation.
Typedef for QFlags<Permission> which contains an OR combination of Permission values.
Refer to QFileDevice::Permission for the enum documentation.
This enum describes the errors that may be returned by error().
Constant | Value | Description |
---|---|---|
QFileDevice::NoError | 0 | No error occurred. |
QFileDevice::ReadError | 1 | Error occurred when reading from the file. |
QFileDevice::WriteError | 2 | Error occurred when writing to the file. |
QFileDevice::FatalError | 3 | Fatal error occurred. |
QFileDevice::ResourceError | 4 | Out of resources (e.g., too many open files, out of memory, etc.) |
QFileDevice::OpenError | 5 | File could not be opened. |
QFileDevice::AbortError | 6 | Operation was aborted. |
QFileDevice::TimeOutError | 7 | Timeout occurred. |
QFileDevice::UnspecifiedError | 8 | Unspecified error occurred. |
QFileDevice::RemoveError | 9 | File could not be removed. |
QFileDevice::RenameError | 10 | File could not be renamed. |
QFileDevice::PositionError | 11 | Position in the file could not be changed. |
QFileDevice::ResizeError | 12 | File could not be resized. |
QFileDevice::PermissionsError | 13 | File could not be accessed. |
QFileDevice::CopyError | 14 | File could not be copied. |
This enum is used when opening a file to specify additional options which only apply to files and not to a generic QIODevice.
Constant | Value | Description |
---|---|---|
QFileDevice::DontCloseHandle | 0 | If not explicitly closed, the underlying file handle is left open when the QFile object is destroyed. |
QFileDevice::AutoCloseHandle | 0x0001 | The file handle passed into open() should be closed by close(), the default behavior is that close just flushes the file and the application is responsible for closing the file handle. When opening a file by name, this flag is ignored as CopeprSpice always owns the file handle and must close it. |
This enum describes special options that may be used by the map() method.
Constant | Value | Description |
---|---|---|
QFileDevice::NoOptions | 0 | No options. |
This enum is used by the permission() function to report the permissions and ownership of a file. The values may be OR-ed together to test multiple permissions and ownership values.
Constant | Value | Description |
---|---|---|
QFileDevice::ReadOwner | 0x4000 | Readable by the owner of the file. |
QFileDevice::WriteOwner | 0x2000 | Writable by the owner of the file. |
QFileDevice::ExeOwner | 0x1000 | Executable by the owner of the file. |
QFileDevice::ReadUser | 0x0400 | Readable by the user. |
QFileDevice::WriteUser | 0x0200 | Writable by the user. |
QFileDevice::ExeUser | 0x0100 | Executable by the user. |
QFileDevice::ReadGroup | 0x0040 | Readable by the group. |
QFileDevice::WriteGroup | 0x0020 | Writable by the group. |
QFileDevice::ExeGroup | 0x0010 | Executable by the group. |
QFileDevice::ReadOther | 0x0004 | Readable by anyone. |
QFileDevice::WriteOther | 0x0002 | Writable by anyone. |
QFileDevice::ExeOther | 0x0001 | Executable by anyone. |
Because of differences in the platforms supported by CopperSpice the semantics of ReadUser, WriteUser and ExeUser are platform dependent.
On Unix, the rights of the owner of the file are returned and on Windows the rights of the current user are returned. On NTFS file systems ownership and permissions checking is disabled by default for performance reasons. To enable it include the following line.
Permission checking is then turned on and off by incrementing and decrementing qt_ntfs_permission_lookup
by 1.
QFileDevice::~QFileDevice | ( | ) |
Destroys the QFileDevice and close any open files if necessary.
|
overridevirtual |
Returns true if the end of the file has been reached, otherwise returns false.
For empty device files on Unix this method will always return true, since the file system reports that the size of such a file is zero. You should not call atEnd() when reading data from a device file, instead call read() until no more data can be read.
Reimplemented from QIODevice::atEnd()
|
overridevirtual |
Calls QFileDevice::flush() and closes the file. Errors from flush are ignored.
Reimplemented from QIODevice::close()
FileError QFileDevice::error | ( | ) | const |
Returns the file error status.
The I/O device status returns an error code. For example, if open() returns false
, or a read/write operation returns -1, this function can be called to find out the reason why the operation failed.
|
virtual |
Returns the name of the device file. The default implementation in QFileDevice returns an empty string.
Reimplemented in QTemporaryFile::fileName(), QSaveFile::fileName(), QFile::fileName()
bool QFileDevice::flush | ( | ) |
Flushes any buffered data to the file. Returns true if successful, otherwise returns false.
int QFileDevice::handle | ( | ) | const |
Returns the file handle of this QFileDevice. This is a small positive integer, suitable for use with C library functions such as fdopen() and fcntl(). If the file is not open, or there is an error, handle() returns -1.
On systems which use file descriptors for sockets like Unix systems the handle can be used with QSocketNotifier as well.
|
overridevirtual |
Returns true if this QFileDevice can only be read or written sequentially, otherwise returns false. Most files support random access, but some special files may not.
Reimplemented from QIODevice::isSequential()
uchar * QFileDevice::map | ( | qint64 | offset, |
qint64 | size, | ||
MemoryMapFlags | flags = NoOptions |
||
) |
Maps size bytes of the file into memory starting at offset. Returns a pointer to the memory or a nullptr if there is an error.
A file should be open for a map to succeed but the file does not need to stay open after the memory has been mapped. When the QFile is destroyed or a new file is opened with this object, any maps that have not been unmapped will automatically be unmapped. Any mapping options can be passed through flags.
|
virtual |
Returns the complete OR-ed together combination of QFile::Permission for this QFileDevice.
Reimplemented in QFile::permissions()
|
overridevirtual |
Reimplemented from QIODevice::pos()
Implements QIODevice::readData()
Reimplemented from QIODevice::readLineData()
|
virtual |
Sets the QFileDevice size (in bytes) to size. Returns true if the QFileDevice resize succeeds, otherwise returns false. If the file size is increased the new data will set to 0. If the file size is decreased the file is truncated.
Reimplemented in QFile::resize()
|
overridevirtual |
For random-access devices this method sets the current position to pos returning true on success, or false if an error occurred. For sequential devices the default behavior is to do nothing and return false.
Seeking beyond the end of a file: If the position is beyond the end of a file, then seek() shall not immediately extend the file. If a write is performed at this position, then the file shall be extended. The content of the file between the previous end of file and the newly written data is UNDEFINED and varies between platforms and file systems.
Reimplemented from QIODevice::seek()
|
virtual |
Sets the permissions for the file to the permissionSpec specified. Returns true> if successful, or false if the permissions can not be modified.
Reimplemented in QFile::setPermissions()
|
overridevirtual |
Returns the size of the file. For device files on Unix this method returns zero. The contents of such a file are generated on demand in response to calling read().
Reimplemented from QIODevice::size()
bool QFileDevice::unmap | ( | uchar * | address | ) |
Unmaps the memory address. Returns true if the unmap succeeds, false otherwise.
void QFileDevice::unsetError | ( | ) |
Sets the file error to QFileDevice::NoError.
Implements QIODevice::writeData()
Reimplemented in QSaveFile::writeData()