Chapter Contents |
Previous |
Next |
Standard Libraries |
Text and Binary Access |
When a stream is associated with an external file, the
default access mode is text. You can specify
ios::binary
in the open mode if you need binary access, as in the
following statement:
ostream object("tso:fred.obj", ios::out|ios::binary);
Filenames |
style:name |
Under OS/390, the following filename styles are supported:
tso
: style
names most closely resemble typical filenames under UNIX systems.
Under CMS, the following filename styles are supported:
You can change the default style for your program by including a declaration
for an external
char*
variable named
_style
. For example, the following
statement specifies that by default all filenames are to be interpreted as
tso:
style names:
char *_style = "tso:";
Amparms |
To successfully
and efficiently use a file on IBM 370 systems, it is often necessary to provide
information about actual or desired file attributes in addition to the filename.
For example, when you create a new file under OS/390, it may be necessary
to specify the file size and how large the records are to be. File attributes
of this sort are specified via amparms, which are keyword parameters
defined by the SAS/C library. Amparms can be specified as a third argument
to an
fstream
constructor or
open()
member function. For example,
the following statements specify that the DDname SYSLIN should define a file
with fixed-length 80-byte records, grouped into blocks of 3,200 characters:
ostream objfile; objfile.open("syslin", ios::out|ios::binary, "recfm=f,reclen=80,blksize=3200");
The translator supports the same amparms as the SAS/C Compiler, as described in the SAS/C Library Reference, Volume 1.
An additional optional argument to stream constructors
and
open()
member functions is an access method name. For instance, the
following statement defines an
iostream
processed by the "rel" access
method.
iostream work("dsn:&wkfile", ios::out|ios:binary, "alcunit=cyl,space=5","rel");
File Positioning |
The streams library defines two different types to deal
with file positioning,
streampos
and
streamoff
. The streampos type is
used to hold file positions, while
streamoff
is used to hold offsets
of one point in a file from another.
In UNIX implementations of C++, both
streampos
and
streamoff
are integral types and both may be used freely with any
file. However, in the SAS/C implementation, only
streamoff
is an integral type. Further,
streamoff
can only be used for files that behave like UNIX files,
namely, those opened for binary access using the "rel" access method.
streampos
is a nonintegral type that encodes a file position in a system-dependent
manner. You can use the
tellg()
and
tellp()
member functions to obtain
a
streampos
for a particular
point in the file, and you can use the
seekg()
and
seekp()
functions
to position to a point whose location has previously been determined. Because
no arithmetic or other operations are defined on
streampos
values, more general positioning
operations such as seeking 10,000 characters past a specific location in the
file are not supported.
Other Differences between UNIX and 370 I/O |
370 I/O
is not based on file descriptors. For this reason, member functions such as
fd()
and
attach()
are not meaningful in the IBM 370 environment
and are not supported. Similarly, UNIX protection modes are not meaningful
to OS/390 or CMS and constructors or
open()
calls that specify a protection
mode will be rejected at compile time.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.