Truncating a file (was: ... in System V)

Chris Torek chris at mimsy.umd.edu
Sun Nov 12 16:02:02 AEST 1989


In article <986 at dialogic.UUCP> drich at dialogic.UUCP (Dan Rich) writes:
>	int ftruncate(fd,length) 
>	int fd;
>	off_t length;
>ftruncate() causes the file refered to by fd to have a size
>equal to length bytes. ... If it was shorter, bytes between the
>old and new lengths are read as zeros.

Unless it is a BSD system (i.e., not a SunOS system), in which
case ftruncate does what its name suggests: *truncates* the file,
rather than set its size.  In other words, if it was shorter, the
file remains shorter.

It would have been nice if, while changing the operation, Sun had
changed the name as well.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list