Re: File editing

new topic     » goto parent     » topic index » view thread      » older message » newer message

I think a possible solution to prepend sequence A to file B might be to do
this :
Open file B (for binary append) and append to it (rubbish) bytes of length
A. Close B.
Open B( for binary update(?)) and move the original sequence to the end of
the file.
I suppose that the program structure to do the last part would be like this
(in quasi-code):

for pointer= length file B to 1 by -1
get byte B[pointer]
write byte to B[pointer + length A]
end for

Then...
Add sequence A to the front of file B, ie:

for pointer= 1 to length A
get byte A[pointer]
write byte to B[pointer]
end for

Now, this is a very rough answer but I think it has merit because you will
not need to load into Eu anything longer than the sequence A. Also the
above quasi-code logic could be optimized somewhat by reading and writing
chunks of data rather than single bytes.



Yours Truly
Michael Palffy

michael at igrin.co.nz
----------
> From: ThatNerd at AOL.COM
> To: EUPHORIA at cwisserver1.mcs.muohio.edu
> Subject: File editing
> Date: Friday, 24 July 1998 12:08
>
> I was wondering if it was possible to add to the beginning of a
file(prepend
> to a file) without having to copy the contents, add the new stuff then
put the
> old stuff back in. Any help would be appreciated!

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu