_access, _waccess
这个函数是C++中判断文件是否存在以及文件访问权限的非常实用的函数:
# _access 和 _waccess
# Determine file-access permission.
int _access( const char *path, int mode );
int _waccess( const wchar_t *path, int mode );
Routine Required Header Optional Headers Compatibility
_access <io.h> <errno.h> Win 95, Win NT
_waccess <wchar.h> or <io.h> <errno.h> Win NT
# For additional compatibility information, see Compatibility in the Introduction.
# Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
# Return Value
Each of these functions returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or is not accessible in the given mode; in this case, errno is set as follows:
EACCES
Access denied: file’s permission setting does not allow