Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)



  ftruncate(2)                        CLIX                        ftruncate(2)



  NAME

    ftruncate - Truncates a file to a specified length

  LIBRARY

    Berkeley Software Distribution Library (libbsd.a)

  SYNOPSIS

    #include <sys/types.h>

    int ftruncate(
      int fd ,
      off_t length );

  PARAMETERS

    fd      Specifies the file descriptor for the file to be truncated.

    length  Specifies the length in bytes to which the file is to be
            truncated.

  DESCRIPTION

    The ftruncate() function truncates the file referenced by fd to at most
    length bytes.  If the file was larger than length bytes, the extra data is
    lost.  The file must be opened for writing.

  EXAMPLES

    To truncate an open file to 0 bytes:

    if (ftruncate(fd, 0) == -1)
         perror("ftruncate failed");


  RETURN VALUES

    Upon successful completion, a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.

  ERRORS

    The ftruncate() function fails if one or more of the following are true:

    [EBADF]    The descriptor is invalid.

    [EINVAL]   The file is not opened for writing or the descriptor references
               a socket, not a file.




  2/94 - Intergraph Corporation                                              1






  ftruncate(2)                        CLIX                        ftruncate(2)



    [EIO]      An I/O error occurred reading a block to be zeroed.

  RELATED INFORMATION

    Functions:  open(2)

















































  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026