in reply to In place editing without reading further
So, if I understand correctly, this is a file of <1000 bytes of text, followed by a few gigabytes of binary data?
It sounds like the approach you've got works, and as long as the old string is not too short (as checked for by the code), and the end usage doesn't care about trailing whitespace in the field, you should remain fine.
However, I would not expect it to take very long to spin through even a huge file and copy it, as long as you're not trying to parse it. You're already doing sysreads and syswrites, so you're not accidentally going to try and read it a line at a time. Why not just read in reasonably sized chunks, and copy the file if you need to increase the length of the content_architecture value?
How long does it actually take if you read 32k at a time, grow or shrink the first chunk, and then write out to a new file until done? It would be nice to have a scheme that works all the time, and doesn't damage the original file. If you only have to process a few files occasionally, and it takes a minute instead of a second, then the extra safety margin is probably worth it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: In place editing without reading further
by trippledubs (Deacon) on Jan 28, 2015 at 04:18 UTC | |
by SuicideJunkie (Vicar) on Jan 28, 2015 at 14:48 UTC | |
by trippledubs (Deacon) on Jan 29, 2015 at 15:24 UTC | |
by trippledubs (Deacon) on Jan 28, 2015 at 20:21 UTC |