blob: ad7e4883e9bbefa48b51edbf8dcffe7d114ae57b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QProcess>
bool zip()
{
//! [0]
QProcess gzip;
gzip.start("gzip", QStringList() << "-c");
if (!gzip.waitForStarted())
return false;
gzip.write("Qt rocks!");
gzip.closeWriteChannel();
if (!gzip.waitForFinished())
return false;
QByteArray result = gzip.readAll();
//! [0]
gzip.start("gzip", QStringList() << "-d" << "-c");
gzip.write(result);
gzip.closeWriteChannel();
if (!gzip.waitForFinished())
return false;
qDebug("Result: %s", gzip.readAll().data());
return true;
}
int main()
{
zip();
return 0;
}
|