-
Appending mid file
I haven't had to write out to files much...
Right now i open a file and search for something then insert a string after something has been found. My problem is the file doesn't automatically shift to make room for this new text(my insertion erases the old contents). Is there a way to write in the middle of a file and have everything auto shift so that I dont have to copy everything from after where im about to write and re-write it?
Thanks.
-
As soon as you figure out how to make a new piece of disk drive magically appear between those pieces of data, we'll get that in C.
In other words, no.
-
I figured there may be some standard function option that could accomplish this for me, sorry. So the best(I guess only) way to do this is copy everything that im about to overwrite(even though this could eventually be huge), write my buffer, and then rewrite my copy buffer?
-
-
The two above posts are correct. What needs to happen is to read in your original file while writing out your file data to another file while appending your string when appropriate, then continue writing your original file data.
When ever you need to merge two files together, there will be three files needed to get this accomplished, 2 for reading in data and a third for writing and or appending to an existing file.