Results 1 to 2 of 2

Thread: Searching for a patern in a big binary file

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Searching for a patern in a big binary file

    Hi,

    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?

    Carlos.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Searching for a patern in a big binary file

    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()

    Cheers,
    _

Similar Threads

  1. Read binary file
    By jaca in forum Qt Programming
    Replies: 9
    Last Post: 28th March 2012, 09:38
  2. Open a binary file.
    By TJSonic in forum Qt Programming
    Replies: 13
    Last Post: 22nd July 2010, 23:32
  3. Replies: 0
    Last Post: 17th June 2010, 12:07
  4. cannot execute binary file
    By mgturner in forum Installation and Deployment
    Replies: 1
    Last Post: 16th March 2009, 18:04
  5. How to Print a doc file (or binary file) to printer
    By rmagro in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2008, 16:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.