summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp
blob: 01e49400af3911ec62de8dee1ef5718957a3475a (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QCoreApplication>
#include <QFile>

#include <stdio.h>

int main(int argc, char **argv)
{
    QCoreApplication ca(argc, argv);
    QFile f;
    f.open(stdin, QIODevice::ReadOnly);
    QByteArray input;
    char buf[1024];
    qint64 len;
    while ((len = f.read(buf, 1024)) > 0)
        input.append(buf, len);
    f.close();
    QFile f2("fileWriterProcess.txt");
    if (!f2.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
        fprintf(stderr, "Cannot open %s for writing: %s\n",
                qPrintable(f2.fileName()), qPrintable(f2.errorString()));
        return 1;
    }
    f2.write(input);
    f2.close();
    return 0;
}