mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 16:55:25 +08:00
qt 6.5.1 original
This commit is contained in:
11
tests/auto/corelib/io/qfile/stdinprocess/CMakeLists.txt
Normal file
11
tests/auto/corelib/io/qfile/stdinprocess/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## stdinprocess_helper Binary:
|
||||
#####################################################################
|
||||
|
||||
qt_internal_add_test_helper(stdinprocess_helper
|
||||
SOURCES
|
||||
main.cpp
|
||||
)
|
35
tests/auto/corelib/io/qfile/stdinprocess/main.cpp
Normal file
35
tests/auto/corelib/io/qfile/stdinprocess/main.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 <QtCore/QCoreApplication>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
printf("usage: stdinprocess_helper <all|line <0|1>>\n");
|
||||
printf("echos all its input to its output.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
QFile file;
|
||||
|
||||
if (strcmp(argv[1], "all") == 0) {
|
||||
file.open(stdin, QFile::ReadWrite);
|
||||
printf("%s", file.readAll().constData());
|
||||
} else if (strcmp(argv[1], "line") == 0) {
|
||||
if (strcmp(argv[2], "0") == 0) {
|
||||
file.open(stdin, QFile::ReadWrite);
|
||||
} else {
|
||||
file.open(0, QFile::ReadWrite);
|
||||
}
|
||||
|
||||
char line[1024];
|
||||
while (file.readLine(line, sizeof(line)) > 0) {
|
||||
printf("%s", line);
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user