当前位置:网站首页>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
边栏推荐
- Part 7: Lesson 2 general skills of consultants - how to install and uninstall SAP ERP system client
- Record today's MySQL failures
- Qingniao Changping campus of Peking University: can I learn UI with a high school degree?
- 防抖和节流
- 数组 两个数组的交集 II
- ThinkPHP v6.0.x反序列化漏洞复现
- 初中毕业生,选择中职学校也可以升入高等学府
- 【MySQL】表的约束
- JS anchor positioning can extend many functions
- 磁盘序列号,磁盘ID,卷序列号的区别
猜你喜欢

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

构建幼儿Steam教育实施策略

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

Abbexa cell free DNA kit instructions

磁盘序列号,磁盘ID,卷序列号的区别

Interpreting the new ecology of education in maker space

Abbexa 8-OHdG CLIA kit solution

Factory and strategy mode implementation scheme of coupons

C language -- 11 branch statement if else

Exec function of PHP
随机推荐
Notes to entry: do I need to know programming for O & M?
【MySQL】表数据的增删查改(DML)
SQL Server2019安装的详细步骤实战记录(亲测可用)
CCF class a conference or journal - regression related papers
学IT毕业后该去哪个城市?哪个岗位薪资高?哪些公司待遇好?
Abbexa acrylamide peg NHS instructions
SQL Server row to column (pivot), column to row (unpivot)
The process of keyword search in Oracle tables
[nk] 牛客月赛51 F-平均题
Rotate menu 2.0
C language -- 11 branch statement if else
数组 求上升区间的高度和
Share some information I accumulated when I was working as a dotnet9 blog site
How to choose the field of we media video creation?
Install MySQL on Linux system. Problems encountered in xshell
PHP pseudo protocol implementation command execution details
C language -- 10 first knowledge of structure
Apple zoom! It's done so well
MySQL数据库如何查看表占用空间大小
Acl2022 | bert2bert: an efficient pre training method of parameter reuse, which significantly reduces the training cost of oversized models