Go to the first, previous, next, last section, table of contents.


access

Syntax

#include <unistd.h>

int access(const char *filename, int flags);

Description

This function determines what kind of access modes a given file allows. The parameter flags is the logical or of one or more of the following flags:

R_OK
Request if the file is readable. Since all files are readable under MS-DOS, this access mode always exists.
W_OK
Request if the file is writable.
X_OK
Request if the file is executable.
F_OK
Request if the file exists.
D_OK
Request if the file is really a directory.

Return Value

Zero if the requested access mode is allowed, nonzero if not.

Portability

not ANSI, POSIX

Example

if (access("file.ext", W_OK))
  return ERROR_CANNOT_WRITE;
open("file.ext", O_RDWR);


Go to the first, previous, next, last section, table of contents.