ACCESS - see if a file can be accessed.
(Compatible with UNIX System V C)
Usage:
#include <fildes.h>
ret = access( name, mode );
Where:
- char *name;
- points to a string containing the name of the file to be
checked.
- int mode;
- indicates what sort of accessibility is to be determined.
If "mode" is 0, "access" checks for
the file's existence. If "mode" is 1,
"access" checks if the current program can
execute the file. If "mode" is 2,
"access" checks if the current program can
write on the file. If "mode" is 4,
"access" checks if the current program can read
the file.
- int ret;
- is zero if the access is permitted. Otherwise a -1 is
returned and the library variable "errno" is
set to indicate the error (see below).
Description:
"access" determines if the current program can
access a particular file.
Possible Errors:
- errno=ENOENT
- The file or pathname was not found. This can also mean
that "name" was a null string.
- errno=EACCES
- access denied. You do not have permission to access the
file in the requested way.
- errno=FMScode
- "access" can also set "errno" to an
FMS error code indicating the reason for the error.
Notes:
"access" is an attempt to emulate the UNIX
"access" system call. Since the file systems are
different, this emulation cannot be perfect. In particular, an
attempt to "fopen" a file may be denied even if
"access" says the file exists and has permissions.
UNIX users will note that this version of "access"
requires inclusion of <fildes.h>. A different #include file
is needed on UNIX.
On GCOS, "errno" will reflect the FMS status. Also,
if "mode" is zero, "access" returns zero only
if the FMS status definitely indicates that the file exists.
There are conceivable situations where it could be argued that a
"file" "existed" but "access"
returns -1.
In most cases, it is better to avoid using "access".
Instead, open the file with "fopen" and use the error
return status to determine the access status.
See Also:
- expl c include fildes
- for more information about using the "fildes"
routines.
- expl c lib errno
- for more information about values returned in 'errno'.
- expl b syslib f.perm
- for a routine that executes the GCOS "check
permissions" call.
Copyright © 1996, Thinkage Ltd.