Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Inserting

Name: Anonymous 2009-09-03 7:48

are there any open/write functions for C , which do not overwrite chars in a file , but insert them ?

or do i have to write a shitty loop that just reads , stores and writes a char ?

also discuss file and string handling libraries because most that i have seen suck .

Name: Anonymous 2009-09-03 11:07

>>5
unless the data comes in, say, 4kB blocks
And even then, the fucking filesystems provide no interface to do so, so you're fucked either way. You can truncate at the end, but that's it.

Allowing arbitrary byte editing wouldn't hurt as much as some people assume (you'd just need 3 extra bytes per file extent and it would hurt performance a bit when used, but it'd be better than rewriting the whole file - but it's correct it's not a very big use case, not worth implementing)

>>12
This is false. They use two buffers in total: one for everything before the last insertion, and one for everything after. One of them has a bit of padding to avoid a realloc on every new char.

Source: recovering text files from memory dumps of several crahed/hung editors. Also read it somewhere a long time ago.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List