VMS Help  —  CRTL  pread
    Reads bytes from a given position within a file without changing
    the file pointer.

    This function is OpenVMS Alpha and Integrity servers only.

    Format

      #include  <unistd.h>

      ssize_t pread  (int file_desc, void *buffer, size_t nbytes,

                     off_t offset);

1  –  Arguments

 file_desc

    A file descriptor that refers to a file currently opened for
    reading.

 buffer

    The address of contiguous storage in which the input data is
    placed.

 nbytes

    The maximum number of bytes involved in the read operation.

 offset

    The offset for the desired position inside the file.

2  –  Description

    The pread function performs the same action as read, except that
    it reads from a given position in the file without changing the
    file pointer. The first three arguments to pread are the same as
    for read, with the addition of a fourth argument offset for the
    desired position inside the file. An attempt to perform a pread
    on a file that is incapable of seeking results in an error.

3  –  Return Values

    n                  The number of bytes read.
    -1                 Upon failure, the file pointer remains
                       unchanged and pread sets errno to one of the
                       following values:

                       o  EINVAL - The offset argument is invalid.
                          The value is negative.

                       o  EOVERFLOW - The file is a regular file, and
                          an attempt was made to read or write at or
                          beyond the offset maximum associated with
                          the file.

                       o  ENXIO - A request was outside the
                          capabilities of the device.

                       o  ESPIPE - fildes is associated with a pipe
                          or FIFO.
Close Help