#include <unistd.h>
int access_file1 (const char*filename)
{
int ret = -1;
/********** Begin *********/
if(0 == access(filename, F_OK)){
ret=0;
}
/********** End *********/
return ret;
}
int access_file2 (const char*filename)
{
int ret = -1;
/********** Begin *********/
if((0 == access(filename, R_OK))&&(0 == access(filename, W_OK))){
ret=0;
}
/********** End *********/
return ret;
}
int access_file3 (const char*filename)
{
int ret = -1;
/********** Begin *********/
if((0 == access(filename,R_OK))&&(0 == access(filename, X_OK))){
ret=0;
}
/********** End *********/
return ret;
}
int access_file4 (const char*filename)
{
int ret = -1;
/********** Begin *********/
if((0 == access(filename, W_OK))&&(0 == access(filename, X_OK))){
ret=0;
}
/********** End *********/
return ret;
}
检查文件的访问权限
最新推荐文章于 2024-07-12 14:49:40 发布