linux c中的测试文件权限(access)

来源:互联网 发布:库房库存数据分析 编辑:程序博客网 时间:2024/05/18 03:21
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc,char* argv[])
{
  if(access("ceshi",F_OK) == 0)
  {
   printf("文件存在!\n");
  }
  if(access("ceshi",R_OK)==0)
  {
  printf("R");
  }
    if(access("ceshi",W_OK)==0)
  {
  printf("W");
  }
    if(access("ceshi",X_OK)==0)
  {
  printf("X");
  }
  return 0;
}
0 0
原创粉丝点击