View Full Version : Searching for a patern in a big binary file

14th May 2014, 08:06

I have a big binary file (10 GB) that I need to search for a particular pattern. I can see that QByteArray has functions like indexOf() but If I have to search the whole file do I need to do a QFile::readAll() ? And does this means that I need to load all the file in memory?

Which other approach could I use?


14th May 2014, 10:35
You'll probably have to implement a search algorthm that can work with blocks of data.

E.g. read a block, check for the first byte. If found successively search for the next ones, eventually having to read more data.

Alternatively to reading blocks of data one can map a portion of the directly into memory, see QFile::map()