search & replace in binary file

I

Ike

I have a binary file which I must rewrite out to the local disk. In the
process of doing that, there are some 30 character strings I must search and
replace with a different corresponding string to each of those 30 character
strings. Each of these strings is between 10 and 500 bytes long.

Can someone please tell me what htey think the most efficient and effective
way to do this might be? TIA, Ike
 
T

Tony Dahlman

Ike said:
I have a binary file which I must rewrite out to the local disk. In the
process of doing that, there are some 30 character strings I must search and
replace with a different corresponding string to each of those 30 character
strings. Each of these strings is between 10 and 500 bytes long.
Can someone please tell me what htey think the most efficient and effective
way to do this might be? TIA, Ike

Hey Ike! I guess all files are binary, or hex or octal, or something,
aren't
they? Worse yet, the characters could be any language -- did you think of
that?

Anyway, you might want to read in at least 500 bytes at a time, into a
buffer
of at least 1,000 bytes. Then you search and replace as needed. The only
problem I see is if the "local disk" is full and you can't write your
results until you've deleted the previously read portions of the file.

By the way, how are you doing on this? Do you have any code that you
could
share with the folks here? Knowing whether your problem is I/O, i18n, or
proprietary/encoded data, or something else might help readers of the
newsgroup to help you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top