This POSIX function is deprecated beginning in Visual C++ 2005. Use the ISO C++ conformant _access or security-enhanced _access_s instead.
Determines if a file is read-only or not. More secure versions are available; see _access_s, _waccess_s.
int _access(
const char *path,
int mode
);
int _waccess(
const wchar_t *path,
int mode
);
Parameters
path File or directory path.
mode Read/write attribute.
Return Value
Each function returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or does not have the given mode; in this case, errno is set as shown in the following table.
EACCES Access denied: the file's permission setting does not allow specified access.
ENOENT File name or path not found.
EINVAL Invalid parameter.
For more information about these and other return codes, see _doserrno, errno, _sys_errlist, and _sys_nerr.
Remarks
When used with files, the _access function determines whether the specified file or directory exists and has the attributes specified by the value of mode. When used with directories, _access determines only whether the specified directory exists; in Windows 2000 and later operating systems, all directories have read and write access.
mode value Checks file for
00 Existence only
02 Write-only
04 Read-only
06 Read and write
This function only checks whether the file and directory are read-only or not, it does not check the filesystem security settings. For that you need an access token. For more information on filesystem security, see Access Tokens. An ATL class exists to provide this functionality; see CAccessToken Class.
_waccess is a wide-character version of _access; the path argument to _waccess is a wide-character string. _waccess and _access behave identically otherwise.
This function validates its parameters. If path is NULL or mode does not specify a valid mode, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, the function sets errno to EINVAL and returns -1.