This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: fastjar: Small _chsize/ftruncate fix
> DJ Delorie wrote:
> > Using an undocumented function in libiberty, certainly when not also
> > testing for it, is bad.
>
> Perhaps all of the ftruncate code and workarounds and tricks might make
> a good candidate to be added to libiberty?
Yes, if it can be done portably, or at least with portably-detected
features, which often means that you can't rely on runtime checks or
runnable configure tests.
> > Why can't we use the age-old trick of write()ing zero bytes (not a
> > single NUL byte) to truncate a file?
>
> How does this work? This doesnt seem to work:
That's the trick. Hmmm... seems it's unlikely to work on platforms
with ftrunctate or chsize, but then, you wouldn't need it for those.
It's a last-ditch effort. It's been around since MS-DOS 2.0.