SYNOPSIS
#include <unistd.h>
int ftruncate(int fildes, off_t length);
int ftruncate64(int fildes, off64_t length);
DESCRIPTION
The
If the file was previously longer than length, bytes past length are lost. If the file was shorter, bytes between the old and the new length are read in as zeros. The effective user ID of the process must have write permission for the file, and the file must be open for writing.
These functions do not modify the file offset for any open file descriptors associated with the file. On successful completion, if the file size is changed, these functions mark the st_ctime and st_mtime fields of the file for update.
The
PARAMETERS
RETURN VALUES
If successful,
- EBADF
-
fildes is not a file descriptor that is open for writing.
- EFBIG
-
The file is a regular file and its length is greater than the offset maximum established in the open file description associated with fildes.
- EINTR
-
A signal interrupted the call.
- EINVAL
-
The length argument was less than 0.
The fildes argument references a file that was opened without write permission.
- EINVAL
-
fildes does not correspond to an ordinary file.
- ETXTBSY
-
The file exists, mandatory file/record locking is set, and there are outstanding record locks on the file.
CONFORMANCE
UNIX 98.
MULTITHREAD SAFETY LEVEL
MT-Safe.
PORTING ISSUES
None.
AVAILABILITY
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
- Functions:
open() ,truncate()
- Miscellaneous:
- lf64
PTC MKS Toolkit 10.5 Documentation Build 40.