Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Notes on record-oriented I/O

&pagelevel(5)&pagelevel

Record-oriented I/O is possible for SAM, ISAM and PAM files.

When the fopen() and freopen() functions are called, the file must always be opened in binary mode and with the option type=record.

With the creat() or freopen() functions, the file must always be opened in binary mode and the specification of O_RECORD.

I/O functions that read or write characters or strings (up to \n) cannot be used for recordoriented input/output.

Available I/O functions

The following functions are available for processing files with stream I/O:

creat(), fopen(),
freopen(), open()

Open

close(), fclose()

Close

fread(), read()

Read

fwrite(), write()

Write

fsetpos(), fgetpos()

Set file position to determined location

fseek(), lseek()

Set file position to start/end of file

rewind()

Set file position to start of file

flocate()

Explicitly positioning in an ISAM file

fdelrec()

Delete a record in an ISAM file

In addition, the following functions for file processing and error handling can be used unchanged:

feof(), ferror(), clearerr(), unlink(), remove(), rename()

All I/O functions not listed here are unavailable for record-oriented input/output and will be rejected with an error return value.
It should be noted, however, that no checks are performed for the two macros getc() and putc() for performance reasons. If these macros are used on files with record-orientedI/O, the behavior is undefined.

Processing a file with record-oriented and stream-oriented I/O

Files created for record-oriented I/O can be opened for stream-oriented I/O and vice versa. However, stream-oriented I/O does not support all the file attributes that are possible for record-oriented I/O.

FCBTYPE of a new file to be created

The FCBTYPE of a new file to be created can be defined as follows:

  • Specification in an ADD-FILE-LINK command and use of the LINK name in the fopen() or freopen() function

  • Specification of the forg parameter in the fopen() or freopen() function:forg=seq: a SAM file is created.
    forg=key: an ISAM file is created.

The following restrictions apply to the FCBTYPE of a file and the entries for fopen() and freopen():

  • If type=record is specified, the FCBTYPE of the file must be SAM, PAM or ISAM.

  • If forg=seq is specified, the FCBTYPE of the file must be SAM or PAM.

  • If forg=key is specified, the FCBTYPE of the file must be ISAM.

  • The append mode "a" is not allowed for ISAM files. The position is determined by the key in the record.

The following restrictions apply to the FCBTYPE of a file and the entries for creat() and open():

  • If O_RECORD is specified the file must have FCBTYPE SAM, PAM or ISAM.

Multiple keys for ISAM files

By default, multiple keys are not permitted for ISAM files. They may, however, be used if DUP-KEY=Y is specified in an ADD-FILE-LINK command.