File System

File System truncate

truncate

// PROTOTYPE
int truncate(const char* pathname, off_t length)

Truncate a file to a given length.

  • pathname: The pathname to the file (Unix-style, with forward slash as the directory separator).
  • length: length in bytes.

Returns 0 on success. On error, returns -1 and sets errno. Some possible errno values include:

  • ENOENT: File does not exist.
  • ENOSPC There is no space on the file system.