VMS Help  —  CRTL  ftruncate
    Truncates a file to a specified length.

    Format

      #include  <unistd.h>

      int ftruncate  (int filedes, off_t length);

1  –  Arguments

 filedes

    The descriptor of a file that must be open for writing.

 length

    The new length of the file, in bytes. The off_t data type is
    either a 32-bit or 64-bit integer. The 64-bit interface allows
    for file sizes greater than 2 GB, and can be selected at compile
    time by defining the _LARGEFILE feature-test macro as follows:

    CC/DEFINE=_LARGEFILE

2  –  Description

    The ftruncate 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.

3  –  Return Values

    0                  Indicates success.
    -1                 An error occurred; errno is set to indicate
                       the error.
Close Help