1// qfiledevice.sip generated by MetaSIP 2// 3// This file is part of the QtCore Python extension module. 4// 5// Copyright (c) 2021 Riverbank Computing Limited <info@riverbankcomputing.com> 6// 7// This file is part of PyQt5. 8// 9// This file may be used under the terms of the GNU General Public License 10// version 3.0 as published by the Free Software Foundation and appearing in 11// the file LICENSE included in the packaging of this file. Please review the 12// following information to ensure the GNU General Public License version 3.0 13// requirements will be met: http://www.gnu.org/copyleft/gpl.html. 14// 15// If you do not wish to use this file under the terms of the GPL version 3.0 16// then you may purchase a commercial license. For more information contact 17// info@riverbankcomputing.com. 18// 19// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 20// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 21 22 23class QFileDevice : QIODevice /NoDefaultCtors/ 24{ 25%TypeHeaderCode 26#include <qfiledevice.h> 27%End 28 29public: 30 enum FileError 31 { 32 NoError, 33 ReadError, 34 WriteError, 35 FatalError, 36 ResourceError, 37 OpenError, 38 AbortError, 39 TimeOutError, 40 UnspecifiedError, 41 RemoveError, 42 RenameError, 43 PositionError, 44 ResizeError, 45 PermissionsError, 46 CopyError, 47 }; 48 49 enum Permission 50 { 51 ReadOwner, 52 WriteOwner, 53 ExeOwner, 54 ReadUser, 55 WriteUser, 56 ExeUser, 57 ReadGroup, 58 WriteGroup, 59 ExeGroup, 60 ReadOther, 61 WriteOther, 62 ExeOther, 63 }; 64 65 typedef QFlags<QFileDevice::Permission> Permissions; 66 67 enum FileHandleFlag 68 { 69 AutoCloseHandle, 70 DontCloseHandle, 71 }; 72 73 typedef QFlags<QFileDevice::FileHandleFlag> FileHandleFlags; 74 virtual ~QFileDevice(); 75 QFileDevice::FileError error() const; 76 void unsetError(); 77 virtual void close() /ReleaseGIL/; 78 virtual bool isSequential() const; 79 int handle() const; 80 virtual QString fileName() const; 81 virtual qint64 pos() const; 82 virtual bool seek(qint64 offset) /ReleaseGIL/; 83 virtual bool atEnd() const; 84 bool flush() /ReleaseGIL/; 85 virtual qint64 size() const; 86 virtual bool resize(qint64 sz); 87 virtual QFileDevice::Permissions permissions() const; 88 virtual bool setPermissions(QFileDevice::Permissions permissionSpec); 89 90 enum MemoryMapFlags 91 { 92 NoOptions, 93%If (Qt_5_4_0 -) 94 MapPrivateOption, 95%End 96 }; 97 98 void *map(qint64 offset, qint64 size /ResultSize/, QFileDevice::MemoryMapFlags flags = QFileDevice::NoOptions) [uchar * (qint64 offset, qint64 size, QFileDevice::MemoryMapFlags flags = QFileDevice::NoOptions)]; 99 bool unmap(void *address) [bool (uchar *address)]; 100 101protected: 102 virtual SIP_PYOBJECT readData(qint64 maxlen) /TypeHint="Py_v3:bytes;str",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; 103%MethodCode 104 // Return the data read or None if there was an error. 105 if (a0 < 0) 106 { 107 PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative"); 108 sipIsErr = 1; 109 } 110 else 111 { 112 char *s = new char[a0]; 113 qint64 len; 114 115 Py_BEGIN_ALLOW_THREADS 116 #if defined(SIP_PROTECTED_IS_PUBLIC) 117 len = sipSelfWasArg ? sipCpp->QFileDevice::readData(s, a0) : sipCpp->readData(s, a0); 118 #else 119 len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0); 120 #endif 121 Py_END_ALLOW_THREADS 122 123 if (len < 0) 124 { 125 Py_INCREF(Py_None); 126 sipRes = Py_None; 127 } 128 else 129 { 130 sipRes = SIPBytes_FromStringAndSize(s, len); 131 132 if (!sipRes) 133 sipIsErr = 1; 134 } 135 136 delete[] s; 137 } 138%End 139 140 virtual qint64 writeData(const char *data /Array/, qint64 len /ArraySize/) /ReleaseGIL/; 141 virtual SIP_PYOBJECT readLineData(qint64 maxlen) /TypeHint="Py_v3:bytes;str",ReleaseGIL/ [qint64 (char *data, qint64 maxlen)]; 142%MethodCode 143 // Return the data read or None if there was an error. 144 if (a0 < 0) 145 { 146 PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative"); 147 sipIsErr = 1; 148 } 149 else 150 { 151 char *s = new char[a0]; 152 qint64 len; 153 154 Py_BEGIN_ALLOW_THREADS 155 #if defined(SIP_PROTECTED_IS_PUBLIC) 156 len = sipSelfWasArg ? sipCpp->QFileDevice::readLineData(s, a0) : sipCpp->readLineData(s, a0); 157 #else 158 len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0); 159 #endif 160 Py_END_ALLOW_THREADS 161 162 if (len < 0) 163 { 164 Py_INCREF(Py_None); 165 sipRes = Py_None; 166 } 167 else 168 { 169 sipRes = SIPBytes_FromStringAndSize(s, len); 170 171 if (!sipRes) 172 sipIsErr = 1; 173 } 174 175 delete[] s; 176 } 177%End 178 179public: 180%If (Qt_5_10_0 -) 181 182 enum FileTime 183 { 184 FileAccessTime, 185 FileBirthTime, 186 FileMetadataChangeTime, 187 FileModificationTime, 188 }; 189 190%End 191%If (Qt_5_10_0 -) 192 QDateTime fileTime(QFileDevice::FileTime time) const; 193%End 194%If (Qt_5_10_0 -) 195 bool setFileTime(const QDateTime &newDate, QFileDevice::FileTime fileTime); 196%End 197}; 198 199QFlags<QFileDevice::Permission> operator|(QFileDevice::Permission f1, QFlags<QFileDevice::Permission> f2); 200