On Mon, Aug 23, 2010 at 05:29:28PM +0100, Matthew Booth wrote:
You assume above that you know in advance how large the file
you're
writing will be. As I said, you could move that truncate-size to the
end, but mixing paths and handles is nasty and occasionally
error-prone.
Consider:
h = hopen_file("/foo");
hwrite ...;
hwrite ...;
mv("/foo", "/bar");
hwrite ...;
hwrite ...;
truncate("/foo", x);
You've now created 2 files rather than 1. If you use htruncate
rather than truncate here it's robust to any changes in paths.
OK, so you can poke your own eye out ...
This is all being accessed from a single program. I think you just
should take care not to do that.
Nevertheless we can start without these APIs and add them later if
there is a pressing need. But I thought the original point of handles
was for optimization, and we don't need to optimize something which is
done exactly once.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
New in Fedora 11: Fedora Windows cross-compiler. Compile Windows
programs, test, and build Windows installers. Over 70 libraries supprt'd
http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw