#include <sys/types.h>
int truncate(path, length) char *path; off_t length;
int ftruncate(fd, length) int fd; off_t length;
truncate() causes the file referred to by path (or for ftruncate() the object referred to by fd) to have a size equal to length bytes. If the file was previously longer than length, the extra bytes are removed from the file. If it was shorter, bytes between the old and new lengths are read as zeroes. With ftruncate(), the file must be open for writing.
truncate() returns:
truncate() may set errno to:
Write permission is denied for the file referred to by path.
A pathname component is longer than {NAME_MAX} (see sysconf.2v while {_POSIX_NO_TRUNC} is in effect (see pathconf.2v
ftruncate() may set errno to:
fd refers to a socket, not to a file.
These calls should be generalized to allow ranges of bytes in a file to be discarded.
Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97