Back to index

glibc  2.9
truncate.c File Reference
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>

Go to the source code of this file.


int truncate (char *path, off_t length) const

Function Documentation

int truncate ( char *  path,
off_t  length 
) const

Definition at line 26 of file truncate.c.

  int fd, ret, save;

  fd = open (path, O_WRONLY);
  if (fd < 0)
    return -1;

  ret = ftruncate (fd, length);
  save = errno;
  (void) close (fd);
  if (ret < 0)
    __set_errno (save);
  return ret;

Here is the call graph for this function: