BL> I've just been fiddling trying to read and write to the same
BL> file without much success, so I gave it up and read files.20 into an
BL> array and then wrote in back separately, to avoid having to use a
BL> temp file which bloody useless C is unable to erase properly like a
BL> decent language like Pascal can do with one leg in the air.
??? There are a swag of ways of doing that. Besides harcoding remove()
and rename(), you could use tmpnam() or tmpfile() rather than hardcoding a
name, and then rather than hardcode temp.20, you could take it as a
parameter too.
BL> This is the revised utility which removes the zero length files from
BL> files.20 without using a temp file. It's limited to 512 lines which
BL> ought to be enough. The only catch I can see is that it rewrites
BL> files.20 with the actual data in memory, and if something went wrong
BL> at that point you'd be rooted.
I don't think you can even make a statement that 512 is enough. I'm sure
that will bite me in the bum one day. The current utility works as is, but
if you want to add remove() and rename(), that is fine too. BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|