Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:07:23

0001 // Copyright (C) 2020 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QFILEDEVICE_H
0005 #define QFILEDEVICE_H
0006 
0007 #include <QtCore/qiodevice.h>
0008 #include <QtCore/qstring.h>
0009 
0010 QT_BEGIN_NAMESPACE
0011 
0012 class QDateTime;
0013 class QFileDevicePrivate;
0014 
0015 class Q_CORE_EXPORT QFileDevice : public QIODevice
0016 {
0017 #ifndef QT_NO_QOBJECT
0018     Q_OBJECT
0019 #endif
0020     Q_DECLARE_PRIVATE(QFileDevice)
0021 
0022 public:
0023     enum FileError {
0024         NoError = 0,
0025         ReadError = 1,
0026         WriteError = 2,
0027         FatalError = 3,
0028         ResourceError = 4,
0029         OpenError = 5,
0030         AbortError = 6,
0031         TimeOutError = 7,
0032         UnspecifiedError = 8,
0033         RemoveError = 9,
0034         RenameError = 10,
0035         PositionError = 11,
0036         ResizeError = 12,
0037         PermissionsError = 13,
0038         CopyError = 14
0039     };
0040 
0041     enum FileTime {
0042         FileAccessTime,
0043         FileBirthTime,
0044         FileMetadataChangeTime,
0045         FileModificationTime
0046     };
0047 
0048     enum Permission {
0049         ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000,
0050         ReadUser  = 0x0400, WriteUser  = 0x0200, ExeUser  = 0x0100,
0051         ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010,
0052         ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001
0053     };
0054     Q_DECLARE_FLAGS(Permissions, Permission)
0055 
0056     enum FileHandleFlag {
0057         AutoCloseHandle = 0x0001,
0058         DontCloseHandle = 0
0059     };
0060     Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag)
0061 
0062     ~QFileDevice();
0063 
0064     FileError error() const;
0065     void unsetError();
0066 
0067     void close() override;
0068 
0069     bool isSequential() const override;
0070 
0071     int handle() const;
0072     virtual QString fileName() const;
0073 
0074     qint64 pos() const override;
0075     bool seek(qint64 offset) override;
0076     bool atEnd() const override;
0077     bool flush();
0078 
0079     qint64 size() const override;
0080 
0081     virtual bool resize(qint64 sz);
0082     virtual Permissions permissions() const;
0083     virtual bool setPermissions(Permissions permissionSpec);
0084 
0085     enum MemoryMapFlag {
0086         NoOptions = 0,
0087         MapPrivateOption = 0x0001
0088     };
0089     Q_DECLARE_FLAGS(MemoryMapFlags, MemoryMapFlag)
0090 
0091     uchar *map(qint64 offset, qint64 size, MemoryMapFlags flags = NoOptions);
0092     bool unmap(uchar *address);
0093 
0094     QDateTime fileTime(QFileDevice::FileTime time) const;
0095     bool setFileTime(const QDateTime &newDate, QFileDevice::FileTime fileTime);
0096 
0097 protected:
0098     QFileDevice();
0099 #ifdef QT_NO_QOBJECT
0100     QFileDevice(QFileDevicePrivate &dd);
0101 #else
0102     explicit QFileDevice(QObject *parent);
0103     QFileDevice(QFileDevicePrivate &dd, QObject *parent = nullptr);
0104 #endif
0105 
0106     qint64 readData(char *data, qint64 maxlen) override;
0107     qint64 writeData(const char *data, qint64 len) override;
0108     qint64 readLineData(char *data, qint64 maxlen) override;
0109 
0110 private:
0111     Q_DISABLE_COPY(QFileDevice)
0112 };
0113 
0114 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::Permissions)
0115 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::FileHandleFlags)
0116 Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::MemoryMapFlags)
0117 
0118 QT_END_NAMESPACE
0119 
0120 #endif // QFILEDEVICE_H