_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 specified acce

_access和_waccess是C++中用于检查文件是否存在和访问权限的函数。它们返回0表示允许访问,-1表示禁止。这些函数不考虑文件系统安全设置,仅检查是否可读,并提供宽字符版本。当文件不存在、权限不足或参数无效时,会返回相应的错误代码。文章包含使用示例。
最低0.47元/天 解锁文章
9204

被折叠的 条评论
为什么被折叠?



