1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.core.filedevice;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.datetime;
19 import qt.core.flags;
20 import qt.core.global;
21 import qt.core.iodevice;
22 import qt.core.object;
23 import qt.core.string;
24 import qt.helpers;
25 
26 /+ class QDateTime; +/
27 extern(C++, class) struct QFileDevicePrivate;
28 
29 class /+ Q_CORE_EXPORT +/ QFileDevice : QIODevice
30 {
31 /+ #ifndef QT_NO_QOBJECT +/
32     mixin(Q_OBJECT);
33 /+ #endif
34     Q_DECLARE_PRIVATE(QFileDevice) +/
35 
36 public:
37     enum FileError {
38         NoError = 0,
39         ReadError = 1,
40         WriteError = 2,
41         FatalError = 3,
42         ResourceError = 4,
43         OpenError = 5,
44         AbortError = 6,
45         TimeOutError = 7,
46         UnspecifiedError = 8,
47         RemoveError = 9,
48         RenameError = 10,
49         PositionError = 11,
50         ResizeError = 12,
51         PermissionsError = 13,
52         CopyError = 14
53     }
54 
55     enum FileTime {
56         FileAccessTime,
57         FileBirthTime,
58         FileMetadataChangeTime,
59         FileModificationTime
60     }
61 
62     enum Permission {
63         ReadOwner = 0x4000, WriteOwner = 0x2000, ExeOwner = 0x1000,
64         ReadUser  = 0x0400, WriteUser  = 0x0200, ExeUser  = 0x0100,
65         ReadGroup = 0x0040, WriteGroup = 0x0020, ExeGroup = 0x0010,
66         ReadOther = 0x0004, WriteOther = 0x0002, ExeOther = 0x0001
67     }
68     /+ Q_DECLARE_FLAGS(Permissions, Permission) +/
69 alias Permissions = QFlags!(Permission);
70     enum FileHandleFlag {
71         AutoCloseHandle = 0x0001,
72         DontCloseHandle = 0
73     }
74     /+ Q_DECLARE_FLAGS(FileHandleFlags, FileHandleFlag) +/
75 alias FileHandleFlags = QFlags!(FileHandleFlag);
76     ~this();
77 
78     final FileError error() const;
79     final void unsetError();
80 
81     override void close();
82 
83     override bool isSequential() const;
84 
85     final int handle() const;
86     /+ virtual +/ QString fileName() const;
87 
88     override qint64 pos() const;
89     override bool seek(qint64 offset);
90     override bool atEnd() const;
91     final bool flush();
92 
93     override qint64 size() const;
94 
95     /+ virtual +/ bool resize(qint64 sz);
96     /+ virtual +/ Permissions permissions() const;
97     /+ virtual +/ bool setPermissions(Permissions permissionSpec);
98 
99     // ### Qt 6: rename to MemoryMapFlag & make it a QFlags
100     enum MemoryMapFlags {
101         NoOptions = 0,
102         MapPrivateOption = 0x0001
103     }
104 
105     final uchar* map(qint64 offset, qint64 size, MemoryMapFlags flags = MemoryMapFlags.NoOptions);
106     final bool unmap(uchar* address);
107 
108     final QDateTime fileTime(QFileDevice.FileTime time) const;
109     final bool setFileTime(ref const(QDateTime) newDate, QFileDevice.FileTime fileTime);
110 
111 protected:
112     this();
113 /+ #ifdef QT_NO_QOBJECT
114     QFileDevice(QFileDevicePrivate &dd);
115 #else +/
116     /+ explicit +/this(QObject parent);
117     this(ref QFileDevicePrivate dd, QObject parent = null);
118 /+ #endif +/
119 
120     override qint64 readData(char* data, qint64 maxlen);
121     override qint64 writeData(const(char)* data, qint64 len);
122     override qint64 readLineData(char* data, qint64 maxlen);
123 
124 private:
125     /+ Q_DISABLE_COPY(QFileDevice) +/
126 }
127 /+pragma(inline, true) QFlags!(QFileDevice.Permissions.enum_type) operator |(QFileDevice.Permissions.enum_type f1, QFileDevice.Permissions.enum_type f2)/+noexcept+/{return QFlags!(QFileDevice.Permissions.enum_type)(f1)|f2;}+/
128 /+pragma(inline, true) QFlags!(QFileDevice.Permissions.enum_type) operator |(QFileDevice.Permissions.enum_type f1, QFlags!(QFileDevice.Permissions.enum_type) f2)/+noexcept+/{return f2|f1;}+/
129 /+pragma(inline, true) QIncompatibleFlag operator |(QFileDevice.Permissions.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/
130 
131 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDevice::Permissions) +/