Momergil
14th July 2013, 17:31
Hello!
Well, the question is in the title. By now I do that with the following function:
int MReadWrite::getLineNumber()
{
if (!isOpen() || !mFile.isReadable() || !mFile.seek(0))
return -1;
uint numboflines = 0;
while (!mFile.atEnd())
{
numboflines++;
mFile.readLine();
}
if (!mFile.seek(0))
qDebug() << "Failure while trying to put streamer at beginning in getLineNumber().";
return numboflines;
}
But the problem is that I want to avoid the usage of the readLine() function, since reading from the hard disk is quite a slow operation and the content is not being actually used anyway.
Is there another, faster way of doing this?
Thanks,
Momergil
(Btw, in case of the above implementation, would it be any better to use a QTextStream to do the readLine()?)
Well, the question is in the title. By now I do that with the following function:
int MReadWrite::getLineNumber()
{
if (!isOpen() || !mFile.isReadable() || !mFile.seek(0))
return -1;
uint numboflines = 0;
while (!mFile.atEnd())
{
numboflines++;
mFile.readLine();
}
if (!mFile.seek(0))
qDebug() << "Failure while trying to put streamer at beginning in getLineNumber().";
return numboflines;
}
But the problem is that I want to avoid the usage of the readLine() function, since reading from the hard disk is quite a slow operation and the content is not being actually used anyway.
Is there another, faster way of doing this?
Thanks,
Momergil
(Btw, in case of the above implementation, would it be any better to use a QTextStream to do the readLine()?)