access/_access函数

简介: access/_access函数

Linux下


1,头文件:


#include <unistd.h>


2,函数的声明:


int access(const char *pathname, int mode);


3,函数的作用:


access函数用来判断指定的文件或目录是否存在(F_OK),已存在的文件或目录是否有可读(R_OK)、可写(W_OK)、可执行(X_OK)权限。F_OK、R_OK、W_OK、X_OK这四种方式通过access函数中的第二个参数mode指定


4,函数的返回值:

如果指定的方式有效,则此函数返回0,否则返回-1。


5,事例:

判断是否允许读取/etc/passwd


#include <unistd.h>
int main()
{
    if(access("/etc/passwd", R_OK) == 0)
    printf("/etc/passwd can be read\n");
}


结果如下:


cda18c1bd66e470e9707d79ea3a6ba9f.png

相关文章
|
数据安全/隐私保护
cross-region access is not allowed
cross-region access is not allowed
147 1
|
7月前
|
JavaScript 前端开发
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
has been blocked by CORS policy: The ‘Access-Control-Allow-Origin‘ header contains multiple values ‘
151 0
|
安全 JavaScript 前端开发
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
|
JavaScript Java 应用服务中间件
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
2014 0
Vue 跨域问题 的几种解决办法 (No ‘Access-Control-Allow-Origin‘ header is present on the requested resource)
|
前端开发 数据可视化 Java
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
报错:跨域问题解决 No ‘Access-Control-Allow-Origin‘ header is present on the requested resource.
1290 0
|
SQL 数据库 关系型数据库
|
网络协议 网络安全 iOS开发