Re: Adding/Removing byes from the beginning of a file

new topic     » goto parent     » topic index » view thread      » older message » newer message
GreenEuphorian said...
BRyan said...
GreenEuphorian said...

How to add/remove bytes from the beginning of a (binary) file?

Thanks

Green Euphorian

How about reading the whole file into a sequence.

Chop the front off the sequence and write the sequence back into the file.

If there is another way, I would prefer it, because the file might be huge (even hundreds of MBs, or even GBs, so loading the whole thing into memory would not be a good idea. Any other suggestions please?

I haven't tried this, but you could probably use file_num = open("my_file", "u") to open text file for update (reading and writing), then copy data within the file a section at a time to limit memory useage, using seek, getc, putc, or other functions in http://openeuphoria.org/docs/std_io.html. I'm not sure how to reduce the size of the file, but i believe it grows if you write past the end of the file.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu