Accessing Files Programmer's Guide (32650-90885)

Chapter 5 99
Opening a File
Opening a Device File
Opening a Device File
Device files are files that are currently being input to or output from a nonshareable device
(any peripheral device except a disk). Because all file open operations are accomplished
through the file system, you can open files on very different devices in a standard,
consistent way, using the HPFOPEN or FOPEN intrinsics. Furthermore, the name and
characteristics assigned to a file when it is defined in a program do not restrict that file to
residing on the same device every time the program is run. In these cases, the file system
temporarily overrides the programmatic characteristics with those characteristics
required by the device.
The following topics provide you with further discussions concerning device files, as well as
two program examples to illustrate how to open a magnetic tape file:
"Device-Dependent File Characteristics" discusses those file characteristics affected by
particular devices.
"New and permanent device files" discusses the domains required by various
input/output devices.
"Opening an unlabeled magnetic tape file" shows an example of an HPFOPEN call that
opens an unlabeled magnetic tape file (see example 5-5).
"Opening a labeled magnetic tape file" shows an example of an HPFOPEN call that opens
a labeled magnetic tape file (see example 5-6).
Device-dependent file characteristics
Certain physical and access characteristics for device files are restricted by the devices on
which the file resides. For your convenience, device-dependent restrictions for several
devices are summarized in Table 5-1. on page 99
Table 5-1. Device-Dependent Restrictions
DEVICE TYPE RESTRICTED FILE CHARACTERISTICS
Terminal
(parallel input/output device)
record format option
= undefined-length records
block factor option
= 1
inhibit buffering option
= NOBUF
ASCII/binary option
= ASCII
Magnetic tape drive
(serial input/output device)
No restrictions
Line printer/plotter
(serial output device)
domain option
= NEW
record format option
= undefined-length records
access type option
=Write only
block factor option
= 1
Laser printer
(serial output device)
Initially and always spooled
access type option
=Write only
All other restrictions same as for line printer