Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qfiledevice.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFILEDEVICE_H
5#define QFILEDEVICE_H
6
7#include <QtCore/qiodevice.h>
8#include <QtCore/qstring.h>
9
11
12class QDateTime;
14
15class Q_CORE_EXPORT QFileDevice : public QIODevice
16{
17#ifndef QT_NO_QOBJECT
19#endif
20 Q_DECLARE_PRIVATE(QFileDevice)
21
22public:
23 enum FileError {
25 ReadError = 1,
26 WriteError = 2,
27 FatalError = 3,
28 ResourceError = 4,
29 OpenError = 5,
30 AbortError = 6,
31 TimeOutError = 7,
32 UnspecifiedError = 8,
33 RemoveError = 9,
34 RenameError = 10,
35 PositionError = 11,
36 ResizeError = 12,
37 PermissionsError = 13,
38 CopyError = 14
39 };
40
41 enum FileTime {
45 FileModificationTime
46 };
47
49 ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000,
50 ReadUser = 0x0400, WriteUser = 0x0200, ExeUser = 0x0100,
51 ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010,
52 ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001
53 };
54 Q_DECLARE_FLAGS(Permissions, Permission)
55
57 AutoCloseHandle = 0x0001,
58 DontCloseHandle = 0
59 };
60 Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)
61
63
64 FileError error() const;
65 void unsetError();
66
67 void close() override;
68
69 bool isSequential() const override;
70
71 int handle() const;
72 virtual QString fileName() const;
73
74 qint64 pos() const override;
75 bool seek(qint64 offset) override;
76 bool atEnd() const override;
77 bool flush();
78
79 qint64 size() const override;
80
81 virtual bool resize(qint64 sz);
82 virtual Permissions permissions() const;
83 virtual bool setPermissions(Permissions permissionSpec);
84
86 NoOptions = 0,
87 MapPrivateOption = 0x0001
88 };
89 Q_DECLARE_FLAGS(MemoryMapFlags, MemoryMapFlag)
90
91 uchar *map(qint64 offset, qint64 size, MemoryMapFlags flags = NoOptions);
92 bool unmap(uchar *address);
93
94 QDateTime fileTime(QFileDevice::FileTime time) const;
95 bool setFileTime(const QDateTime &newDate, QFileDevice::FileTime fileTime);
96
97protected:
99#ifdef QT_NO_QOBJECT
101#else
102 explicit QFileDevice(QObject *parent);
104#endif
105
106 qint64 readData(char *data, qint64 maxlen) override;
107 qint64 writeData(const char *data, qint64 len) override;
108 qint64 readLineData(char *data, qint64 maxlen) override;
109
110private:
111 Q_DISABLE_COPY(QFileDevice)
112};
113
114Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::Permissions)
115Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::FileHandleFlags)
116Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::MemoryMapFlags)
117
119
120#endif // QFILEDEVICE_H
\inmodule QtCore\reentrant
Definition qdatetime.h:257
\inmodule QtCore
Definition qfiledevice.h:16
Permission
This enum is used by the permission() function to report the permissions and ownership of a file.
Definition qfiledevice.h:48
FileHandleFlag
This enum is used when opening a file to specify additional options which only apply to files and not...
Definition qfiledevice.h:56
@ FileMetadataChangeTime
Definition qfiledevice.h:44
FileError
This enum describes the errors that may be returned by the error() function.
Definition qfiledevice.h:23
\inmodule QtCore \reentrant
Definition qiodevice.h:34
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
virtual qint64 readLineData(char *data, qint64 maxlen)
Reads up to maxSize characters into data and returns the number of characters read.
virtual qint64 writeData(const char *data, qint64 len)=0
Writes up to maxSize bytes from data to the device.
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,...
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i....
\inmodule QtCore
Definition qobject.h:90
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
a resize(100000)
QMap< QString, QString > map
[6]
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLbitfield flags
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLenum GLsizei len
GLuint GLuint64EXT address
@ NoError
Definition main.cpp:34
#define Q_OBJECT
unsigned char uchar
Definition qtypes.h:27
long long qint64
Definition qtypes.h:55
QByteArray readData()
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent