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

相关文章
|
10月前
|
数据安全/隐私保护
cross-region access is not allowed
cross-region access is not allowed
116 1
|
3月前
|
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 ‘
85 0
|
8月前
|
安全 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.
|
API
【已解决】No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
No ‘Access-Control-Allow-Origin‘ header is present on the requested resource
334 0
【已解决】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.
1213 0
|
Linux
解决checkPermissions Missing write access to
解决checkPermissions Missing write access to
278 0
|
分布式计算 MaxCompute Java
ODPS-0420095: Access Denied
最近想用阿里的MaxCompute,然后我自己写了一个mr程序,用MaxCompute Studio中的一键发布"Deploy to server"后,用客户端去执行jar,抛出了Access Denied的异常,请问是我没有开通MaxCompute的缘故吗?(目前申请使用的MaxCompute是开发版),还是我配置的问题?Exception in thread "main" com.
2687 0
|
SQL 数据库 关系型数据库
|
网络协议 网络安全 iOS开发