

#include <unistd.h> int access(const char *path, int amode);
SAS/C enables the header file <fcntl.h> to be included in
place of <unistd.h>.
access function determines if a file exists and if that
file can be read or written. path points to a filename of
any style. The type of access tested for is given by amode,
which can be the sum of one or more of the following symbols:
F_OK
R_OK
W_OK
X_OK
F_OK with
another symbol. X_OK is ignored, except for OpenEdition
hierarchical file system (HFS) files.
access function returns 0 if the file exists and if the
type (or types) of access specified by amode is allowed. If
the file does not exist or the specified type of access is not
allowed, - 1 is returned.
A 0 return value from access does not necessarily mean that the
file can be opened, even if the type of access is allowed. For
example, a file may fail to open because incorrect DCB information is
specified. A - 1 return value always indicates that the file
cannot be opened with the specified type of access.
CMS
If the filemode is not specified, * is used, unless amode
indicates that write access is to be tested. In this case, A1 is
used as the filemode.
If the filename is in xed style and XEDIT is not active or the
file is not found in XEDIT, the file is searched for on disk. Write
access (W_OK ) is not allowed for xed or sfd style
files.
Under CMS, the access function cannot be used with VSAM files.
amode value can be tested for any device type. If the mode is
not valid for a device, - 1 is returned.
#include <fcntl.h>
#include <stdio.h>
main()
{
int rc;
/* Does the program have read and write access to the */
/* TSO ISPF profile dataset? */
rc = access("tso:ispf.profile", R_OK + W_OK);
if (rc == 0)
puts("Read and write access exists.");
else
puts("Read and write access does not exist.");
/* Does the member DATA1 exist in the partitioned */
/* dataset referred to by the ddname MYPROG? */
rc = access("tso:myprog(data1)", 0);
if (rc == 0)
puts("File exists.");
else
puts("File does not exist.");
/* Can SYS1.PARMLIB be updated? */
rc = access("dsn:sys1.parmlib", W_OK);
if (rc == 0)
puts("Yes, SYS1.PARMLIB can be updated.");
else
puts("SYS1.PARMLIB cannot be updated.");
}
cmsstat, stat
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.