Chapter Contents |
Previous |
Next |
I/O Functions |
New Applications |
fseek
and
ftell
functions, which are
more widely available than
fsetpos
or
fgetpos
. Note that you cannot use file positions
arithmetically with these functions. (You may be forced to use
fsetpos
and
fgetpos
rather than
fseek
and
ftell
if you need to support very large files.)
fsetpos
and
fgetpos
, or restrict the application to using
files suitable for
"rel"
access. The advantage
of UNIX style I/O is that it is applicable to most files and is somewhat portable.
The advantage of
fsetpos
and
fgetpos
is that they are defined by the C Standard, so they are portable.
The advantage of restricting the application to files suitable for
"rel"
access is that maximum efficiency is achieved
with the most portable interface. If the file is only used by C programs
(for example, if the file is a work file, or if it is not accessed by the
outside world), then requiring suitable file attributes is clearly the best
solution.
afread
and
afwrite
. These routines are especially useful if the records may contain
control characters (which makes standard I/O text access inappropriate).
fsetpos
and
fgetpos
rather than
fseek
and
ftell
for file positioning. These routines have fewer restrictions and their results
are more easily interpreted.
Existing Applications |
fseek
and
ftell
for file positioning, you must modify the program or restrict
it to use only the
"rel"
access method.
(Such an application could be modified to use UNIX style I/O or to use
fsetpos
and
fgetpos
for positioning.) Further modifications or restrictions on file type
may be required if the program cannot tolerate the addition of trailing nulls
at end of file.
"rel"
access, because then the file can be processed without copying. If the program
does not depend on some of the details of UNIX style I/O (for instance, if
it is not sensitive to the exact nature of file positions), it can be converted
to use standard I/O for better performance.
lseek
to do file
positioning, it requires substantial modification. The library does not support
file positioning by character number when UNIX style I/O is used to access
a file as text.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.