Is there a way to truncate a file in the middle of it? For example, if I have a 4096-byte file, and the file pointer is at 80 bytes, I just want to delete the next 1024 bytes from that pointer and nothing else. Is there a way to truncate a file in the middle like that, operating only on the file itself?
To start, ftruncate() only deletes at the end of the file. I could certainly store the preceding and following sections of the file in vars and just put those together -- that's very easy -- but since I'm working on memory constraints (the files I'm working on are at least 100MB,) I wanted to know if there's a better/simpler way...?
Truncate file in the middle?
Moderator: General Moderators