Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 11
Opening Unstructured Files
Opening Unstructured Files
You open an unstructured file as you would any other file, by using the FILE_OPEN_
procedure.
INT FILE^NUM;
.
.
CALL FILE_OPEN_(FILE^NAME:LENGTH,
FILE^NUM,
!access!,
!exclusion!,
!nowait^depth!,
SYNC^DEPTH);
This example opens the file for reading and writing with waited I/O. Refer to Section 3,
Coordinating Concurrent File Access, for information on access and exclusion modes
and to Section 4, Using Nowait Input/Output, for a discussion of waited versus nowait
I/O.
A sync depth of 1 permits retryable write requests against the file when automatically
recovering from path errors. In other words, the sync depth ensures that your data
does not get corrupted due to path errors.
Positioning, Reading, and Writing With Unstructured Files
Unstructured files can be accessed sequentially. Random access is also possible if
the byte address of the data you need is known; you set the byte address using the
POSITION procedure. To begin sequential access anywhere except at the beginning
of the file, you need to set the pointers to the starting byte address.
Refer to Section 2, Using the File System, for details of how to access data in an
unstructured file, including a discussion on the function of the file pointers.
Locking With Unstructured Files
Sometimes you need to ensure exclusive access to a given file or record for a limited
time, for example, while a transaction is in progress. As with any disk file, you can lock
other processes out of an unstructured file by using the LOCKFILE procedure or out of
a given record by using the LOCREC procedure.