【转载】 C中的access函数
分类: C/C++
int access(const char *filename, int amode);
amode参数为0时表示检查文件的存在性,如果文件存在,返回0,不存在,返回-1。
这个函数还可以检查其它文件属性:
06 检查读写权限
04 检查读权限
02 检查写权限
01 检查执行权限
00 检查文件的存在性
而这个就算这个文件没有读权限,也可以判断这个文件存在于否
存在返回0,不存在返回-1
C函数
函数名: access
功 能: 确定文件的访问权限
用 法: int access(const char *filename, int amode);
[编辑本段]access
Synopsis
#include
int _access(const char *path,int mode) ;
Description
The access function, when used with files, determines whether the specified file exists and can be accessed as specified by the value of mode. When used with directories, _access determines only whether the specified directory exists; since under Windows all directories have read and write access.
The mode argument can be one of :
00 Existence only
02 Write permission
04 Read permission
06 Read and write permission
Returns
Zero if the file has the given mode, -1 if an error occurs.
Portability :
Windows. Under Unix a similar function exists too.
Note that lcc-win32 accepts both _access (Microsoft convention) and access.
程序例:
#include <stdio.h>
#include <io.h>
int file_exists(char *filename);
int main(void)
{
printf("Does NOTEXIST.FIL exist: %s\n",
file_exists("NOTEXISTS.FIL") ? "YES" : "NO");
return ;
}
int file_exists(char *filename)
{
return (access(filename, ) == );
}
【转载】 C中的access函数的更多相关文章
- c++ 在Ubuntu系统中使用access函数
include<iostream> #include<stdlib.h> #include<stdio.h> #include<unistd.h> us ...
- [转载]python中multiprocessing.pool函数介绍
原文地址:http://blog.sina.com.cn/s/blog_5fa432b40101kwpi.html 作者:龙峰 摘自:http://hi.baidu.com/xjtukanif/blo ...
- 转载 --- SKLearn中预测准确率函数介绍
混淆矩阵 confusion_matrix 下面将一一给出'tp','fp','fn'的具体含义: 准确率: 所有识别为"1"的数据中,正确的比率是多少. 如识别出来100个结果是 ...
- [转载]Oracle中的NVL函数
Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换函数等等,还有一类函数是通用函数.主要有:NVL,NVL2,NULLIF,COALESCE,这几个函数用在各个类型上都可以. 下面简 ...
- [转载]MATLAB中神经网络的函数
1.设计函数 solvein 设计线性网络: solverb 设计径向基网络: solverbe 设计精确的径向 ...
- 【转载】 Sqlserver中查看自定义函数被哪些对象引用
Sqlserver数据库中支持自定义函数,包含表值函数和标量值函数,表值函数一般返回多个数据行即数据集,而标量值函数一般返回一个值,在数据库的存储过程中可调用自定义函数,也可在该自定义函数中调用另一个 ...
- 转载:java中Thread.sleep()函数使用
点我跳过黑哥的卑鄙广告行为,进入正文. Java多线程系列更新中~ 正式篇: Java多线程(一) 什么是线程 Java多线程(二)关于多线程的CPU密集型和IO密集型这件事 Java多线程(三)如何 ...
- 转载 为什么print在Python 3中变成了函数?
转载自编程派http://codingpy.com/article/why-print-became-a-function-in-python-3/ 原作者:Brett Cannon 原文链接:htt ...
- 【转载】如何在 C#中访问 JavaScript函数?
如何在 C#中访问 JavaScript函数? 时间:13-10-17 栏目:Unity3D教程 作者:zqcyou 评论:0 如何在 C#中访问 JavaScript函数?答案如下:c#代码 ...
随机推荐
- BZOJ 4551: [Tjoi2016&Heoi2016]树
4551: [Tjoi2016&Heoi2016]树 Time Limit: 20 Sec Memory Limit: 128 MBSubmit: 748 Solved: 394[Subm ...
- win10 1607 密匙
win10 1607 安装密钥 GVLK Core=YTMG3-N6DKC-DKB77-7M9GH-8HVX7 Professional=VK7JG-NPHTM-C97JM-9MPGT-3V66T E ...
- WPF中ListBox控件在选择模式(SelectionMode)为Single时仍然出现多个Item被选中的问题
最近在学习WPF过程中使用到了ListBox控件,在使用时遇到下面的奇怪问题: 代码如下: listBox.Items.Add("绘图"); listBox.Items.Add(& ...
- Python: sort,sorted,OrderedDict的用法
Python: sort,sorted,OrderedDict的用法 from http://stqdd.com/archives/427 by 莫亚菜 python对容器内数据的排序有两种,一种是容 ...
- 一个C#解决方案中各文件夹存放了些什么
在VS2015中"生成"(Build)的过程: Source Code(.cs) -> Compile -> Object File(intermediate file ...
- 通过Nginx,Tomcat访问日志(access log)记录请求耗时
一.Nginx通过$upstream_response_time $request_time统计请求和后台服务响应时间 nginx.conf使用配置方式: log_format main '$remo ...
- css006 文本格式化
css006 文本格式化 文本格式化:字体(font-family).颜色(color).字号(font-size). 行距(line-height).粗体(font-weight).斜体(font- ...
- C#------获取最后一个"/"字符后面的所有内容
public ActionResult GetFile(string id) { var path = _db.MailAtchs.Where(p => p.MailID == new Guid ...
- aircrack-ng 多网卡启动后环境清理
#!/bin/sh pkill airodump airmon-ng stop wlan0mon service network-manager restart rm -rf sadsad*
- 蛋疼的vs
这个vs2008 难用的很,要是叫我选肯定vs高版本的,vs2012或者直接vs2015