Read from Stream File (QHFRDSF) API


  Required Parameter Group:

1 Open file handle Input Char(16)
2 Data buffer Output Char(*)
3 Bytes to read Input Binary(4)
4 Bytes actually read Output Binary(4)
5 Error code I/O Char(*)

  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

Message ID Error Message Text
CPF1F2C E Read operation not allowed to file opened for write only.
CPF1F2E E Range of bytes in file in use.
CPF1F25 E File handle not valid.
CPF1F28 E Damaged file.
CPF1F35 E Read file operation failed.
CPF1F4B E Value for number of bytes not valid.
CPF1F41 E Severe error occurred while addressing parameter list.
CPF1F52 E Error code not valid.
CPF1F62 E Requested function failed.
CPF1F66 E Storage needed exceeds maximum limit for user profile &1.
CPF1F71 E Exception specific to file system occurred.
CPF1F72 E Internal file system error occurred.
CPF1F73 E Not authorized to use command.
CPF1F74 E Not authorized to object.
CPF1F82 E Function not supported.
CPF1F87 E Missing or damaged exit program &2.
CPF3C90 E Literal value cannot be changed.
CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.


API introduced: V2R1
Top | Hierarchical File System APIs | APIs by category