I would like to be able to edit the contents of a binary file in C++, and remove all the contents up to a certain character position, which I already know, a bit like removing a header from a file.
One example file I have contains 1.3 million bytes, and I would like to remove the first 38,400, then save the file under the original name.
Currently, I've been doing a buffered read to find the position for each file (the rules for where to cut the file are complex and it is not a simple search), and of course, I could do another buffered read from pos, outputting into a new file, then do a rename, or something along those lines.
But it feels quite heavy handed to have to copy the entire file. Is there any way I can just get the OS (Windows Vista & upwards only - cross-platform not required) to relocate the start of the file, and recycle those 38,400 bytes? Alas, I can find no way, hence why I would ask of you your assistance :)
Thank you so much for any help you can offer.