chsize64

Changes the file size.

Library:LibC
Service:File and Directory I/O

Syntax

  #include <unistd.h> 
   
  int chsize64 (
     int        fildes,
     size64_t   size);
  

Parameters

fildes

(IN) Specifies a file descriptor.

size

(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.

Return Values

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

Decimal

Constant

Description

4

EBADF

The fildes parameter isn't a valid file descriptor or doesn't point to file opened for writing.

6

EACCES

Permission denied.

12

ENOSPC

Insufficient space on the device to extend the file.

Remarks

The chsize64 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 chsize64 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 chsize64 fails, the size of the file remains unchanged.

The chsize64 function is equivalent to chsize except that it handles files larger than 2 GB.

See Also

eof