Go to the previous, next section.
int ftruncate(int fd, size_t length);
int truncate(char *path, size_t length);
Those calls truncate a file to a specified length. In the case of
ftruncate
, the file must be opened for writing.
fd: [in] the file descriptor to truncate.
path: [in] points to the path of the file to truncate.
length: [in] the new size of the file.
On success zero is returned. On error, -1 is returned and errno
is
set to one of the following values:
for ftruncate
:
ENOENT
: the file is invalid.
EBADF
, EACCESS
.
for truncate
:
ENOTDIR
, EINVAL
, ENAMETOOLONG
, ENOENT
,
EACCESS
, ELOOP
, EISDIR
, EROFS
,
ETXTBSY
, EIO
or EFAULT
.
Go to the previous, next section.