How to read a file that is greater than 4G with Qt?
thank you.
How to read a file that is greater than 4G with Qt?
thank you.
The same way you do a smaller file. You just need to use long long integers more carefully.
output for my test file:Qt Code:
#include <QtCore> #include <QDebug> int main(int argc, char **argv) { qDebug() << file.size(); bool ok = file.seek( 4097 * 1024 * 1024LL ); qDebug() << ok; qDebug() << data.size(); file.close(); } return 0; }To copy to clipboard, switch view to plain text mode
thank you.
I know that in C++/C,the seek function has a start mode(current ,begin,or end),but the seek method of QFile has no the parameter,where does it begin from where the position move forward?
In a random-access file it seeks to the specified byte starting from the front of the file, just like fseek() with SEEK_SET. Combine it with QFile::pos() and QFile::size() to get other behaviours.
Bookmarks