[comp.sys.ibm.pc] truncate

graham@convex.com (Marv Graham) (02/09/90)

Neither Borland's TC 2.0 nor Zortech's ZTC 2.06 have a function
which acts like the UN*X truncate() function.  Is equivalent
functionality available?  Where?

toma@tekgvs.LABS.TEK.COM (Tom Almy) (02/10/90)

In article <5280@convex.convex.com> graham@convex.com (Marv Graham) writes:
>Neither Borland's TC 2.0 nor Zortech's ZTC 2.06 have a function
>which acts like the UN*X truncate() function.  Is equivalent
>functionality available?  Where?

I don't know off the top of my head how to do it in these languages, but
I do know the MSDOS calls necessary to do the job.  First you position
the file to where you want eof, and then you write zero bytes to the file.
You'll never get this to work from within C via the stdio functions fseek()
and fwrite()*, but there is a chance that lseek() and write() will do the job,
assuming they pass the calls direct to dos without trying to do funny stuff
(I could imagine an implementation of write() which specifically checks for
a zero length write and does nothing so as to match UNIX functionality).

Tom Almy
toma@tekgvs.labs.tek.com
Standard Disclaimers Apply


* Because of buffering