linux C函数之access函数的用法
来源:互联网 发布:网络信息监控采集技术 编辑:程序博客网 时间:2024/06/06 20:34
1.函数功能:
检查调用进程是否可以对指定的文件执行某种操作。
2.函数原型:
1)函数头文件
#include <stdio.h>#include <unistd.h>
2)函数
int access(const char * pathname, int mode)
3)形参
pathname:需要检测的文件路劲名
mode:需要测试的操作模式。
4)函数返回值说明
成功执行时,返回0。失败返回-1,errno被设为以下的某个值
EINVAL: 模式值无效
EACCES: 文件或路径名中包含的目录不可访问
ELOOP : 解释路径名过程中存在太多的符号连接
ENAMETOOLONG:路径名太长
ENOENT:路径名中的目录不存在或是无效的符号连接
ENOTDIR: 路径名中当作目录的组件并非目录
EROFS: 文件系统只读
EFAULT: 路径名指向可访问的空间外
EIO:输入输出错误
ENOMEM: 不能获取足够的内核内存
ETXTBSY:对程序写入出错
5)mode说明
R_OK 测试读许可权W_OK 测试写许可权X_OK 测试执行许可权F_OK 测试文件是否存在
3.函数实例
#include <stdio.h>#include <unistd.h>int main(void){if(access("test.txt", R_OK)==0) printf("READ OK\n"); if(access("test.txt", W_OK)==0) printf("WRITE OK\n"); if(access("test.txt", X_OK)==0) printf("EXEC OK\n"); if(access("test.txt", F_OK)==0) printf("File exist\n");}
- linux C函数之access函数的用法
- linux C之access的函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux C之access函数
- linux - access函数的用法
- Linux c access 函数
- 执行./ggsci报错error while loading shared libraries: libnnz10.so
- Android 4.0 隐藏虚拟按键(导航栏)的方法
- vi出的提示** already locked,session is read-only
- leetcode_question_5 Longest Palindromic Substring
- java判断与循环语句
- linux C函数之access函数的用法
- 逆序输出--求余运算符的应用
- java 编程基础
- 【Leetcod】Unique Binary Search Trees II
- 关于windows API 和linux API的思考
- hdu1532 Drainage Ditches (Dinic)
- Jdbc连接数据库
- 面试应该如何面?
- IOS笔记——UIScrollView属性介绍