当前位置:网站首页>C language to judge whether a file or folder exists
C language to judge whether a file or folder exists
2022-06-10 22:10:00 【m0_ sixty million seven hundred and twenty-one thousand five hu】
C Language determines whether a file or folder exists
Collect information collected on the Internet , The following methods are summarized to determine whether a file or folder exists , Note the header file references for each function .
One 、 Use access
Function definition
#include <unistd.h>
int access(const char * pathname, int mode);Function description
It can be used to determine whether a file or directory exists , access() Will check if it can read / Write an existing file ,access() Only for authority verification , Ignore the form or content of the document , therefore , If a directory is represented as " Writable ", Indicates that you can create new files in this directory , It doesn't mean that this directory can be treated as a file
pathname Is the path to the file or folder , The current directory directly uses the file or folder name ;mode Indicates the inspection mode , common 4 Patterns :
R_OK, 4Only judge whether you have read permission , This corresponds to the... In the macro definition00 There is onlyW_OK, 2Only judge whether you have write permission , This corresponds to the... In the macro definition02 Write permissionsX_OK, 1Judge whether there is executive authority , This corresponds to the... In the macro definition04 Read permissionF_OK, 0Just judge whether it exists , This corresponds to the... In the macro definition05 Read and write permissions
- Return value
If the specified access method is valid , Then the function returns 0, no
边栏推荐
- [nk] 牛客月賽51 G計算題
- Tableau auto - fabriqué
- C语言qsort()函数的使用(详解)
- 数组 两数之和
- The system needs to scan all the files and try to identify the cover of the video
- 【生成对抗网络学习 其一】经典GAN与其存在的问题和相关改进
- Only this is the most true reason why leaders promote you. The rest is nonsense!
- Are you still writing the TS type code
- PHP pseudo protocol implementation command execution details
- . Net open source free lunch is over?
猜你喜欢

C language -- 7 operators
![[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?](/img/3a/1376593d02adf29a1c37d894dcc0fa.png)
[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?

在模仿学习中进步的智能机器人

C language -- 4 first-time constant
php伪协议实现命令执行详情

Explain in detail the arithmetic operators related to matrix operation in MATLAB (addition, subtraction, multiplication, division, point multiplication, point division, power)

Install MySQL on Linux system. Problems encountered in xshell

Acl2022 | bert2bert: an efficient pre training method of parameter reuse, which significantly reduces the training cost of oversized models

Forward slash "/", backslash "\," escape character "\" and file path separator cannot be clearly remembered

Abbexa low sample size chicken lysozyme C (Lyz) ELISA Kit
随机推荐
System reinstallation and system performance query
oc swift 混编
C语言-排序中的快速排序(简称快排)
C中字符串查找
Intelligent robot making progress in imitation learning
Cordova plugin /jpush phonegap Aurora push_ Local push_ Message push
[nk] Niuke monthly competition 51 f-average question
An analysis of SQL query optimization principle (900w+ data from 17s to 300ms)
The process of keyword search in Oracle tables
Interpreting the new ecology of education in maker space
C language -- 4 first-time constant
Part 7: Lesson 2 general skills of consultants - how to install and uninstall SAP ERP system client
北大青鸟昌平校区:高中学历可以学UI吗?
As a programmer, is it really that important for the underlying principles?
ThinkPHP v6.0.x反序列化漏洞复现
Principle of gravure overprint and factors affecting overprint
php的exec函数
Notes to entry: do I need to know programming for O & M?
C语言qsort()函数的使用(详解)
2022-06-09 rk817 PMU battery temperature detection