Include:
Prototype: int access(char *path, int mode);
mode: 00 (existence) 04 (read permission)
02 (write permission) 06 (read & write permission)
Returns: 0 if path has mode, or -1 if it does not have the given mode or
if it does not exist.
errno: EACCES, ENOENT
See also: chmod, fstat, open, stat
With files, the access function determines whether or not the specified file
exists and can be accessed in mode. The possible mode values and their
meanings in the access call are as follows:
Value Meaning
00 Check for existence only
02 Check for write permission
04 Check for read permission
06 Check for read and write permission
With directories, access determines only whether the specified directory
exists; under MS-DOS(R) and OS/2, all directories have read and write access.
Return Value
The access function returns the value 0 if the file has the given mode. A
return value of -1 indicates that the named file does not exist or is not
accessible in the given mode, and errno is set to one of the following
values: EACCES, ENOENT.