Read from Stream File (QHFRDSF) API


  Required Parameter Group:


  Default Public Authority: *USE

  Threadsafe: No

The Read from Stream File (QHFRDSF) API reads a specified number of bytes from a stream file opened with an access mode of read only or read/write.

The read operation starts at the current position of the file pointer, the location in the file where the next read or write operation occurs. When a file is opened with the Open Stream File (QHFOPNSF) API the file pointer is set to the first byte of the file (position 0). You can move the pointer explicitly with the Change File Pointer (QHFCHGFP) API; see page Change File Pointer (QHFCHGFP) API for details. After the read operation, the file pointer value is increased by the number of bytes actually read.


Authorities and Locks

None.


Required Parameter Group

Open file handle
INPUT; CHAR(16)

The file handle returned when the file was opened with the QHFOPNSF API. Your application must have opened the file with an access mode of read only or read/write.

Data buffer
OUTPUT; CHAR(*)

The buffer that holds the data read from the file.

Bytes to read
INPUT; BINARY(4)

The number of bytes to read from the file, starting at the current file pointer position. The number must be less than or equal to the length of the data buffer.

Bytes actually read
OUTPUT; BINARY(4)

The number of bytes actually read and returned in the data buffer.

The value of this parameter equals the value of the bytes-to-read input parameter unless an error occurs or the end of the file is reached. Reaching the end of the file is not an error. When the file pointer reaches the end of the file, the file system stores the bytes actually read in the data buffer and sets the actual number of bytes read, which in this case is less than the number of bytes to read. The application can then detect the end of the file by comparing the number of bytes actually read to the number requested.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Error Messages



API introduced: V2R1

[ Back to top | Hierarchical File System APIs | APIs by category ]