Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_corelib_io_qiodevice.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5QProcess gzip;
6gzip.start("gzip", QStringList() << "-c");
7if (!gzip.waitForStarted())
8 return false;
9
10gzip.write("uncompressed data");
11
13while (gzip.waitForReadyRead())
14 compressed += gzip.readAll();
16
17
19qint64 CustomDevice::bytesAvailable() const
20{
21 return buffer.size() + QIODevice::bytesAvailable();
22}
24
25
27QFile file("box.txt");
29 char buf[1024];
30 qint64 lineLength = file.readLine(buf, sizeof(buf));
31 if (lineLength != -1) {
32 // the line is available in buf
33 }
34}
36
37
39bool CustomDevice::canReadLine() const
40{
41 return buffer.contains('\n') || QIODevice::canReadLine();
42}
44
45
48{
49 char buf[2];
50 if (file->peek(buf, sizeof(buf)) == sizeof(buf))
51 return (buf[0] == 'M' && buf[1] == 'Z');
52 return false;
53}
55
56
58bool isExeFile(QFile *file)
59{
60 return file->peek(2) == "MZ";
61}
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qfile.h:93
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:904
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
qint64 peek(char *data, qint64 maxlen)
virtual qint64 bytesAvailable() const
Returns the number of bytes that are available for reading.
virtual bool canReadLine() const
Returns true if a complete line of data can be read from the device; otherwise returns false.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLenum GLuint buffer
GLenum GLuint GLenum GLsizei const GLchar * buf
long long qint64
Definition qtypes.h:60
QFile file
[0]
bool isExeFile(QFile *file)
[3]
QProcess gzip
[0]
QByteArray compressed