Finding pattern in large binary file using C or C++? -


i have ~700 mb binary file (non-text data); search specific pattern of bytes occurs in random locations throughout file. e.g. 0x? 0x? 0x55 0x? 0x? 0x55 0x? 0x? 0x55 0x? 0x? 0x55 , on 50 or bytes in sequence. pattern i'd searching sequence 2 random bytes 0x55 occurring every 2 bytes.

that is, search tables stored in file 0x55 being delimiter, , save data contained in tables or otherwise manipulate it.

would best option going through every individual byte 1 @ time, , looking ahead 2 bytes see if value 0x55, , if is, looking ahead again , again confirm table exists in location?

load whole thing? fseek? buffer chunks, searching 1 byte @ time?

what best way of looking through large file, , finding pattern, using c or c++?

this sounds great job regular expression matcher or deterministic finite automaton. these high-power tools designed you're asking, , if have them @ disposal shouldn't have trouble doing sort of search. in c++, consider looking boost.regex libraries, should have functionality need knock problem down.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -