Read from a file without moving the file pointer
#include <unistd.h>
ssize_t pread(int filedes,
void *buff,
size_t nbytes,
off_t offset );
ssize_t pread64( int filedes,
void *buff,
size_t nbytes,
off64_t offset );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The pread() and pread64() functions perform the same action as read(), except that they read from a given position in the file without changing the file pointer. The pread64() function is a large-file support version of pread().
The pread() function reads up to the maximum offset value that can be represented in an off_t for regular files. An attempt to perform a pread() on a file that's incapable of seeking results in an error.
The number of bytes actually read, or -1 if an error occurred (errno is set).
pread() is POSIX 1003.1; pread64() is Large-file support
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | Yes |
| Thread | Yes |