Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 12
Renaming Unstructured Files
Section 3, Coordinating Concurrent File Access, describes how to use the LOCKFILE
procedure to acquire a file lock, and how to remove a file lock using the UNLOCKFILE
procedure. LOCKREC and UNLOCKREC work in a similar way, as follows:
CALL POSITION(FILE^NUM,
RECORD^ADDRESS);
CALL LOCKREC(FILE^NUM);
IF <> THEN ... !could not get the lock
.
.
!protected I/O operations
.
.
CALL UNLOCKREC(FILE^NUM);
The LOCKREC procedure locks the current record (the one addressed by the current-
record pointer). UNLOCKREC removes the lock from the current record. Use care to
ensure that the file pointers are positioned correctly when unlocking the record. If you
have used sequential reads or writes or have done multiple I/O operations to the file
since locking the record, you will need to reset the pointers before unlocking the
record.
Renaming Unstructured Files
You rename an unstructured file as you would any other file, by using the
FILE_RENAME_ procedure. The following procedure call renames the file opened
with file number FILE^NUM.
NAME ':=' "\SYS.$ADMIN.OPERATOR.LOGFILE1" -> @S^PTR;
NAME^LENGTH := @S^PTR '-' @NAME;
ERROR := FILE_RENAME_(FILE^NUM,
NAME:NAME^LENGTH);
IF ERROR <> 0 THEN ...
Note. For files that are protected by the NonStop Transaction Manager/MP (TM/MP), the
acquisition and release of record locks is different from using the Enscribe procedures without
NonStop TM/MP protection. Every modified record gets an implicit lock that is not released,
even by explicit unlock requests, until the transaction ends. Refer to the NonStop TM/MP
Application Programmer’s Guide for details.
Note. You can rename only the subvolume and file ID parts of the file name. You cannot
c
hange the name of the volume on which the file resides. The volume specified must be the
same as the volume the file already resides on.