HELPLIB.HLB  —  CRTL  access
    Checks a file to see whether a specified access mode is allowed.

                                   NOTE

       The access function does not accept network files as
       arguments.

    Format

      #include  <unistd.h>

      int access  (const char *file_spec, int mode);

1  –  Arguments

 file_spec

    A character string that gives an OpenVMS or UNIX style file
    specification. The usual defaults and logical name translations
    are applied to the file specification.

 mode

    Interpreted as shown in Interpretation of the mode Argument.

    Table REF-1 Interpretation of the mode Argument

    Mode
    Argument     Access Mode

    F_OK         Tests to see if the file exists
    X_OK         Execute
    W_OK         Write (implies delete access)
    R_OK         Read

    Combinations of access modes are indicated by ORing the values.
    For example, to check to see if a file has RWED access mode,
    invoke access as follows:

    access (file_spec, R_OK | W_OK | X_OK);

2  –  Description

    The access function checks a file to see whether a specified
    access mode is allowed. If the DECC$ACL_ACCESS_CHECK feature
    logical is enabled, this function checks OpenVMS Access Control
    Lists (ACLs) as well as the UIC protection.

3  –  Return Values

    0                  Indicates that the access is allowed.
    -1                 Indicates that the access is not allowed.

4  –  Example

        #include <unistd.h>
        #include <stdlib.h>
        #include <stdio.h>

        main()
        {
            if (access("sys$login:login.com", F_OK)) {
                perror("ACCESS - FAILED");
                exit(2);
            }
        }
Close Help