access

Gamma: Version 4.0
Prev |  | Next

# `access`

`access` -- checks a file for various permissions.

## Syntax

    access (filename, mode)

## Arguments

`filename`

  The name of a file on disk.

`mode`

  The file mode to be tested. The legal modes are discussed below.

## Returns

Zero is returned if the access `mode` is valid, otherwise -1 is returned and the errno is set.

## Description

This function checks a file for the following permissions. Two or more permissions in bitwise OR combinations can be checked at one time.

- R_OK Test for read permission.

- W_OK Test for write permission.

- X_OK Test for execute permission.

- F_OK Test for existence of file.

The library "const/Filesys.lsp" must be required to use the constants listed above.

## Example

        Gamma> require_lisp("const/Filesys");
        "/usr/cogent/lib/const/Filesys.lsp"
        Gamma> system("touch /tmp/access_test");
        0
        Gamma> system("chmod a=rx /tmp/access_test");
        0
        Gamma> access("/tmp/access_test", R_OK|X_OK);
        0
        Gamma> access("/tmp/access_test", W_OK);
        -1
        Gamma>

See the Starting qserve and nserve section of the Common Functions chapter (Tutorial One), or the Start a Process section of the Common Functions for Any Program chapter (Tutorial Two), or the Linux, QNX 4, or QNX 6 section of the Abstracted Functions chapter in the Cogent Tools Demo and Tutorials book for examples of this function used in context.

## See Also

`is_busy`, `is_file`, `is_readable`, `is_writable`, `errno`

Prev | Home | Next
`absolute_path` | Up | `basename`

Copyright 1995-2002 by Cogent Real-Time Systems, Inc.