#include <unistd.h> ssize_t pread64(int file_descriptor, void *buf, size_t nbyte, off64_t offset);Service Program Name: QP0LLIB1
From the file indicated by file_descriptor, the pread64() function reads nbyte bytes of input into the memory area indicated by buf. The offset value defines the starting position in the file and the file pointer position is not changed.
pread64() is enabled for large files. It is capable of operating on files larger than 2GB minus 1 byte as long as the file has been opened by either of the following:
For additional information about parameters, authorities, and error conditions, see pread()--Read from Descriptor with Offset.
When connecting to a system at release V5R4M5 and earlier, QFileSvr.400 does not support an offset greater than 2 GB minus 1 bytes. Otherwise, offset is limited by the file system being accessed on the server.
The following example opens a file and reads input.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#define _LARGE_FILE_API #include <stdio.h> #include <unistd.h> #include <fcntl.h> main() { int ret, file_descriptor; off64_t off=5; char buf[]="Test text"; if ((file_descriptor = creat64("test.output", S_IWUSR))!= 0) perror("creat64() error"); else { if (-1==(rc=write(file_descriptor, buf, sizof(buf)-1))) perror("write() error"); if (close(file_descriptor)!= 0) perror("close() error"); } if ((file_descriptor = open64("test.output", O_RDONLY)) < 0) perror("open64() error"); else { ret = pread64(file_descriptor, buf, ((sizeof(buf)-1)-off), off); buf[ret] = 0x00; printf("block pread64: \n<%s>\n", buf); if (close(file_descriptor)!= 0) perror("close() error"); } if (unlink("test.output")!= 0) perror("unlink() error"); }
block pread64: <text>