Truncates a file to a specified length.
Format
#include <unistd.h>
int ftruncate (int filedes, off_t length);
Arguments
- filedes
- The descriptor of a file that must be open for writing.
- length
- The new length of the file in bytes.
Description
This function truncates a file at the specified position.
For record files, the position must be a record boundary. Also, the
files must be local, regular files.
If the file was previously larger than length, extra data
is lost. If the file was previously shorter than length,
bytes between the old and new lengths are read as zeros.
Return Values
0 | Indicates success. |
-1 | An error occurred; errno is set
to indicate the error. |
Previous Page | Next Page | Table of Contents | Index