Checks a file to see whether a specified access mode is allowed. This function only checks UIC protection; ACLs are not checked.
#include <unistd.h> int access (const char *file_spec, int mode);
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);
0 | Indicates that the access is allowed. |
-1 | Indicates that the access is not allowed. |
#include <unistd.h> main() { if (access("cdtm$:[c.don]dtm.com",0)) perror("ACCESS - FAILED"), exit(2); }