函数原型int_waccess(constwchar_t*path,intmode);
功能判断是否允许访问。
返回值返回0,则文件为指定的模式。返回-1,则文件不存在或者不能用指定的模式访问。如果在指定的是目录,则仅仅是目录不存在。
参数int_waccess(constwchar_t*path,intmode);
path : 文件路径或目录名。为Unicode字符。
mode:模式
模式
检查文件方式
00
存在
02
允许写
04
允许读
06
允许读和写
示例/* ACCESS.C: This example uses _access to check the
* file named "ACCESS.C" to see if it exists and if
* writing is allowed.
*/
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
/* Check for existence */
if( (_access( "ACCESS.C", 0 )) != -1 )
{
printf( "File ACCESS.C exists
" );
/* Check for write permission */
if( (_access( "ACCESS.C", 2 )) != -1 )
printf( "File ACCESS.C has write permission
" );
}
}