Accessing Files Programmer's Guide (32650-90885)

180 Chapter13
Maintaining File Security
Traditional Mechanism for File Security
file contains 10 logical records of data (numbered 0 through 9). The table shows that the
current end-of-file (EOF) lies at Record 10 before the file is opened, indicating that if
another record were appended to the file, that would be the eleventh record. When you
open the file in the Write-only mode, however, all records presently in the file are deleted
and the logical record pointer and current EOF move to record 0. Now when you write a
record to the file, this will be the first record in that file.
Suppose that you are running a program that opens a magnetic tape file for Write-only
access, but you wish to append records to that file rather than to delete existing records.
You can override the programmatic specifications by using the FILE command to request
Append access to the file, as follows:
FILE TASK; DEV=TAPE; ACC=APPEND
RUN PROGN \
Requests append access
Suppose that you run a program that opens a disk file for write-only access, copies records
into it, and closes it as a permanent file. Under the standard file system security
provisions, the access mode is automatically altered so that the file permits the read, write,
and append access modes (among others). Now, suppose that you run the program a second
Table 13-10. Traditional File Access Mode Types
ACCESS MODE :FILE\
PARAMETER
DESCRIPTION
Read-only IN Permits file to be read but not written on. Used for device
files,such as card reader andpaper tapereader files, as well
as magnetic tape, disk, and terminal output files.
Write-only OUT Permits file to be written on but not read. Any data already
in the file is deleted when the file is opened. Used for device
files, such as card punch and line printer, as well as tape,
disk, and terminal output files.
Write-SAVE OUTKEEP Permits file to be written on but not read, allowing you to
add new records both before and after current end-of-file
indicator. Data is not deleted, but a normal write replaces
it.
Append-only APPEND Permits information to be appended to file, but allows
neither overwriting of current information nor reading of
file. Allows you to add new records after current end-of-file
indicator only. Used when present contents of file must be
preserved.
Read/Write INOUT Permits unrestricted input and output access of file;
information already on file is saved when the file is opened.
(In general, combines features of IN and OUTKEEP.)
Update UPDATE Permits the use of FUPDATE intrinsic to alter records in file.
Record is read into your data stack, altered, and rewritten
to file. All data already in file is saved when the file is
opened.