Hello guys,

im trying to read huge *.dat files (~ 2gb) containing a tag i would like to extract (SoftwareVersionNumber). This piece of code works fine, but the processing time is terrible.

Qt Code:
  1. //Retrieves SW Version of a *.dat file
  2. QString ScanFilesWorker::GetSWVersion(QString strFullPath)
  3. {
  4. QByteArray strTag1 = "<m_SoftwareVersionNumber_aui8>";
  5. QByteArray strTag2 = "</m_SoftwareVersionNumber_aui8>";
  6.  
  7. QFile DatFile(strFullPath);
  8. DatFile.open(QIODevice::ReadOnly);
  9.  
  10. while (!DatFile.atEnd())
  11. {
  12. QByteArray DatContent = DatFile.readLine();
  13. if (DatContent.contains(strTag1))
  14. {
  15. qint64 iFirst = DatContent.lastIndexOf(strTag1);
  16. qint64 iLast = DatContent.lastIndexOf(strTag2);
  17.  
  18. QString SW_Version = DatContent.mid(iFirst+strTag1.length(),iLast-iFirst-strTag2.length()+1);
  19. qDebug() << SW_Version;
  20.  
  21. return SW_Version;
  22. }
  23. }
  24.  
  25. return "No SW Version found!";
  26.  
  27. }
To copy to clipboard, switch view to plain text mode 

DatFile.readAll could be an option, but this function fails for files larger then 600 mb. Maybe it is possible to read through the file from the end to the beginning (SoftwareVersionNumber is located at the end of the file). I also tried QXmlReader library, but it failed as well (*.dat files contain some raw byte data).

Thank you for your help.