7.2 access Function

Determine accessibility of a file

Attention: This interface function is implemented only by MPLAB XC32 C compilers.

Include

<unistd.h>

Prototype

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

Arguments

filename
name of the file to be accessed
how
type of access permitted

Return Value

The return value is 0 if the access is permitted, and -1 otherwise. For the value -1, errno is set to indicate the kind of error. Appropriate values may be EACCES, ENOENT or EROFS, among others.

Remarks

This function is implemented as a stub that must be completed to suit the application.

The access function checks to see whether the file named by filename can be accessed in the way specified by the how argument. The argument either can be the bitwise OR of the flags R_OK, W_OK, X_OK, or the existence test F_OK

This function uses the real user and group IDs of the calling process, rather than the effective IDs, to check for access permission. As a result, if you use the function from a setuid or setgid program, it gives information relative to the user who actually ran the program.

Source File

access.c