Changes the file size.
#include <unistd.h> int chsize ( int fildes, size_t size);
(IN) Specifies a file descriptor.
(IN) Specifies the file size. If size is larger than the current size, the file is extended. If size is smaller than the current size, the file is truncated.
If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following values:
The chsize function changes the size of the file associated with the fildes parameter to the exact size specified by the size parameter. It can truncate or extend the file, depending on the value of size compared to the file’s original size.
The mode in which the file was opened must allow writing.
If chsize extends the file, it appends the null-terminating characters (\0). If it truncates the file, all data beyond the new end-of-file indicator is lost.
If chsize fails, the size of the file remains unchanged.