Set file size in SYSV

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Aug 13 10:14:32 AEST 1989


In article <708 at msa3b.UUCP> kevin at msa3b.UUCP (Kevin P. Kleinfelter) writes:
>O.K. I give up.  How do you set the size of a file in SYSV.
>In particular, I want to take a file which is 1000 bytes, and truncate
>it to 500 bytes WITHOUT COPYING IT.

Not possible in UNIX System V through SVR3.2, probably supported in SVR4.0.

You can simulate this operation by snarfing the intended ultimate file
contents somewhere safe (like an in-memory array, if it will fit, or
a temp file), then use creat() to truncate the file to 0 length, then
write back the desired final contents.



More information about the Comp.unix.questions mailing list