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.
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.
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 nsc lib errno
Copyright © 1996, Thinkage Ltd.