ftruncate64

Truncates a file to the specified length.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <unistd.h> 
   
  int ftruncate64 (
     int       fildes,
     off64_t   len);
  

Parameters

fildes

(IN) Specifies a file descriptor.

len

(IN) Specifies the length of the file.

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

Invalid file descriptor or file descriptor does not refer to a file that has been opened for writing.

9

EINVAL

The fildes parameter refers to a file that was not opened for writing or to a file that was opened without write permission.

The length parameter is less than 0.

28

EIO

An I/O error occurred while reading from or writing to the file system.

63

EINTR

A signal interrupted the operation.

71

EFBIG

The length argument was greater than the maximum file size.

76

EROFS

The specified file resides on a read-only file system.

Remarks

If the size of the file was previously smaller than the len parameter, the ftruncate64 function increases the size of the file to len, and zero fills the extended area.

If the ftruncate64 function fails, the file is unaffected.

The ftruncate64 function is equivalent to ftruncate except that it handles files larger than 2 GB.

See Also