当前位置:网站首页>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
边栏推荐
- 北大青鸟昌平校区:高中学历可以学UI吗?
- Abbkine column exkine Pro animal cell / tissue Total Protein Extraction Kit
- Naturalspeech model synthetic speech achieves human speech level for the first time in CMOS test
- C language -- 7 operators
- Abbexa acrylamide peg NHS instructions
- . Net open source free lunch is over?
- 一次SQL查询优化原理分析(900W+数据从17s到300ms)
- 2022-06-09 RK817 PMU 电池温度检测
- Abbexa 8-OHdG CLIA kit solution
- protoc protoc-gen-go protobuf 之间的关系
猜你喜欢

用少儿编程思维塑造青少年领悟能力

Standard dual airbags, starting from 48900 for butcher Chang'an Lumin

【MySQL】表的约束

As a programmer, is it really that important for the underlying principles?

北大青鸟昌平校区:高中学历可以学UI吗?

C language -- 4 first-time constant

关于type-c

Interpreting the new ecology of education in maker space

Qingniao Changping campus of Peking University: can I learn UI with a high school degree?

构建幼儿Steam教育实施策略
随机推荐
旋转菜单3.0
报错解决Error parsing Mapper XML
Mysql中创建4种索引的不同方式
入行须知:运维需要懂编程吗?
String analysis and use
sql server行转列(pivot),列转行(unpivot)
Abbexa low sample size chicken lysozyme C (Lyz) ELISA Kit
Share this great God's WPF interface design series video
To do desktop plug-in, a good helper for office workers
[nk] 牛客月赛51 F-平均题
C language -- 7 operators
Understanding of related concepts of target detection
JS anchor positioning can extend many functions
Part 7: Lesson 2 general skills of consultants - how to install and uninstall SAP ERP system client
[qingniaochangping campus of Peking University] the coordinated development of vocational education and general education, will this year's high school entrance examination be easy?
旋转导航栏
自制Table錶格
数组 旋转数组
PHP pseudo protocol implementation command execution details
2021年平均工资出炉,IT行业不出所料