header file: unistd.h
int access(const char *path, int mode);
header file: float.h
int _access(const char *path, int mode);
Checks access permissions of a file or pathname.
The Windows version does not use the same macros as the Unix
version for file existence, read permission or write permission.
Further the Windows version does not determine execute/search
permission. Both the Unix and Windows version return -1 on failure
and 0 (zero) on success for matching the mode.
Unix macro values can be mapped to Windows values as
follows:
R_OK 04
W_OK 02
F_OK 00
X_OK (none)
where values may be logically OR'd together.
The function _waccess() is the wide-character version of
_access(). There are versions of these functions with security
enhancements: _access_s() _waccess_s() though these apply to the
CRT only.
Example of Use in Windows
#include <io.h>
int ret;
ret = _access("/temp/myfile.txt", 04);
if (ret == -1) {
/* file not readable */
}
else {
/* file is readable */
}