Re: Adding/Removing byes from the beginning of a file
- Posted by ryanj Feb 21, 2015
- 1707 views
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.