ok this does it:
QString UpdateAvSrc
::getLastLinesFromFile(QString pathToFile,
int lines
) {
if (!file.exists())
return "file doesn't exist...";
file.open(IO_ReadOnly);
file.at(file.size()-1);
int count = 0;
while ( (count <=lines) && (file.at() > 0) )
{
file.at(file.at()-2); /// minus 2 because getch moves one forward
if (ch == '\n')
count++;
}
file.close();
return r;
}
QString UpdateAvSrc::getLastLinesFromFile(QString pathToFile, int lines)
{
QFile file(pathToFile);
if (!file.exists())
return "file doesn't exist...";
file.open(IO_ReadOnly);
file.at(file.size()-1);
int count = 0;
while ( (count <=lines) && (file.at() > 0) )
{
QChar ch = file.getch();
file.at(file.at()-2); /// minus 2 because getch moves one forward
if (ch == '\n')
count++;
}
QString r = file.readAll();
file.close();
return r;
}
To copy to clipboard, switch view to plain text mode
Bookmarks