qfiledevice.sip 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // qfiledevice.sip generated by MetaSIP
  2. //
  3. // This file is part of the QtCore Python extension module.
  4. //
  5. // Copyright (c) 2026 Riverbank Computing Limited <info@riverbankcomputing.com>
  6. //
  7. // This file is part of PyQt6.
  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. class QFileDevice : public QIODevice /NoDefaultCtors/
  22. {
  23. %TypeHeaderCode
  24. #include <qfiledevice.h>
  25. %End
  26. public:
  27. enum FileError
  28. {
  29. NoError,
  30. ReadError,
  31. WriteError,
  32. FatalError,
  33. ResourceError,
  34. OpenError,
  35. AbortError,
  36. TimeOutError,
  37. UnspecifiedError,
  38. RemoveError,
  39. RenameError,
  40. PositionError,
  41. ResizeError,
  42. PermissionsError,
  43. CopyError,
  44. };
  45. enum Permission /BaseType=Flag/
  46. {
  47. ReadOwner,
  48. WriteOwner,
  49. ExeOwner,
  50. ReadUser,
  51. WriteUser,
  52. ExeUser,
  53. ReadGroup,
  54. WriteGroup,
  55. ExeGroup,
  56. ReadOther,
  57. WriteOther,
  58. ExeOther,
  59. };
  60. typedef QFlags<QFileDevice::Permission> Permissions;
  61. enum FileHandleFlag /BaseType=Flag/
  62. {
  63. AutoCloseHandle,
  64. DontCloseHandle,
  65. };
  66. typedef QFlags<QFileDevice::FileHandleFlag> FileHandleFlags;
  67. virtual ~QFileDevice();
  68. QFileDevice::FileError error() const;
  69. void unsetError();
  70. virtual void close() /ReleaseGIL/;
  71. virtual bool isSequential() const;
  72. int handle() const;
  73. virtual QString fileName() const;
  74. virtual qint64 pos() const;
  75. virtual bool seek(qint64 offset) /ReleaseGIL/;
  76. virtual bool atEnd() const;
  77. bool flush() /ReleaseGIL/;
  78. virtual qint64 size() const;
  79. virtual bool resize(qint64 sz);
  80. virtual QFileDevice::Permissions permissions() const;
  81. virtual bool setPermissions(QFileDevice::Permissions permissionSpec);
  82. void *map(qint64 offset, qint64 size /ResultSize/, QFileDevice::MemoryMapFlags flags = QFileDevice::NoOptions) [uchar * (qint64 offset, qint64 size, QFileDevice::MemoryMapFlags flags = QFileDevice::NoOptions)];
  83. bool unmap(void *address) [bool (uchar *address)];
  84. protected:
  85. virtual SIP_PYOBJECT readData(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/ [qint64 (char *data, qint64 maxlen)];
  86. %MethodCode
  87. // Return the data read or None if there was an error.
  88. if (a0 < 0)
  89. {
  90. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  91. sipIsErr = 1;
  92. }
  93. else
  94. {
  95. char *s = new char[a0];
  96. qint64 len;
  97. Py_BEGIN_ALLOW_THREADS
  98. #if defined(SIP_PROTECTED_IS_PUBLIC)
  99. len = sipSelfWasArg ? sipCpp->QFileDevice::readData(s, a0) : sipCpp->readData(s, a0);
  100. #else
  101. len = sipCpp->sipProtectVirt_readData(sipSelfWasArg, s, a0);
  102. #endif
  103. Py_END_ALLOW_THREADS
  104. if (len < 0)
  105. {
  106. Py_INCREF(Py_None);
  107. sipRes = Py_None;
  108. }
  109. else
  110. {
  111. sipRes = PyBytes_FromStringAndSize(s, len);
  112. if (!sipRes)
  113. sipIsErr = 1;
  114. }
  115. delete[] s;
  116. }
  117. %End
  118. virtual SIP_PYOBJECT readLineData(qint64 maxlen) /ReleaseGIL,TypeHint="bytes"/ [qint64 (char *data, qint64 maxlen)];
  119. %MethodCode
  120. // Return the data read or None if there was an error.
  121. if (a0 < 0)
  122. {
  123. PyErr_SetString(PyExc_ValueError, "maximum length of data to be read cannot be negative");
  124. sipIsErr = 1;
  125. }
  126. else
  127. {
  128. char *s = new char[a0];
  129. qint64 len;
  130. Py_BEGIN_ALLOW_THREADS
  131. #if defined(SIP_PROTECTED_IS_PUBLIC)
  132. len = sipSelfWasArg ? sipCpp->QFileDevice::readLineData(s, a0) : sipCpp->readLineData(s, a0);
  133. #else
  134. len = sipCpp->sipProtectVirt_readLineData(sipSelfWasArg, s, a0);
  135. #endif
  136. Py_END_ALLOW_THREADS
  137. if (len < 0)
  138. {
  139. Py_INCREF(Py_None);
  140. sipRes = Py_None;
  141. }
  142. else
  143. {
  144. sipRes = PyBytes_FromStringAndSize(s, len);
  145. if (!sipRes)
  146. sipIsErr = 1;
  147. }
  148. delete[] s;
  149. }
  150. %End
  151. virtual qint64 writeData(SIP_PYBUFFER) /ReleaseGIL/ [qint64 (const char *data, qint64 len)];
  152. %MethodCode
  153. sipBufferInfoDef bi;
  154. if (sipGetBufferInfo(a0, &bi) > 0)
  155. {
  156. Py_BEGIN_ALLOW_THREADS
  157. #if defined(SIP_PROTECTED_IS_PUBLIC)
  158. sipRes = sipSelfWasArg ?
  159. sipCpp->QFileDevice::writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len) :
  160. sipCpp->writeData(reinterpret_cast<char *>(bi.bi_buf), bi.bi_len);
  161. #else
  162. sipRes = sipCpp->sipProtectVirt_writeData(sipSelfWasArg, reinterpret_cast<char *>(bi.bi_buf),
  163. bi.bi_len);
  164. #endif
  165. Py_END_ALLOW_THREADS
  166. sipReleaseBufferInfo(&bi);
  167. }
  168. else
  169. {
  170. sipIsErr = 1;
  171. }
  172. %End
  173. public:
  174. enum FileTime
  175. {
  176. FileAccessTime,
  177. FileBirthTime,
  178. FileMetadataChangeTime,
  179. FileModificationTime,
  180. };
  181. QDateTime fileTime(QFileDevice::FileTime time) const;
  182. bool setFileTime(const QDateTime &newDate, QFileDevice::FileTime fileTime);
  183. enum MemoryMapFlag /BaseType=Flag/
  184. {
  185. NoOptions,
  186. MapPrivateOption,
  187. };
  188. typedef QFlags<QFileDevice::MemoryMapFlag> MemoryMapFlags;
  189. };