waccess

王朝百科·作者佚名  2010-10-10  
宽屏版  字体: |||超大  

函数原型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

" );

}

}

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有