QTextStream atEnd () returns true when reading from file starts
I want to read and parse the contents of the / proc / PID / status file on a linux machine, but QTextStream.atEnd always returns true when reading starts. Code:
QString procDirectory = "/proc/";
procDirectory.append(QString::number(PID));
procDirectory.append("/status");
QFile inputFile(procDirectory);
if (inputFile.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile);
QString line;
while (!in.atEnd())
{
line = in.readLine();
The file exists and if I read the lines manually without a while statement, the files are read fine.
Am I missing something obvious?
(Debian 8 x64, QT 5.4.1 x64, gcc 4.9.2)
+3
source to share