//http://blog.chinaunix.net/uid-24549279-id-71355.html
/*
============================================================================
Name : test.c
Author : blank
Version :
Copyright : Your copyright notice
Description : 程序4-2 access函数实例
============================================================================
*/ #include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "ourhdr.h" #define BUFFSIZE 4096 int main(int argc, char *argv[])
{
if (argc != ){
err_quit("usage: ./test <filename>\n");
} if (access(argv[], R_OK) < ){
err_ret("access error for %s", argv[]);
}else{
printf("read access OK\n");
} if (open(argv[], O_RDONLY) < ){
err_ret("open error for %s", argv[]);
}else{
printf("open for read OK\n");
} exit();
}

程序4-2 access函数实例的更多相关文章

  1. 程序清单 8-8 exec函数实例,a.out是程序8-9产生的可执行程序

    /* ============================================================================ Name : test.c Author ...

  2. 文件和目录之access函数

    本篇博文内容摘自<UNIX环境高级编程>(第二版),仅作个人学习记录所用.关于本书可参考:http://www.apuebook.com/. 当用open函数打开一个文件时,内核以进程的有 ...

  3. 程序4-6 utime函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  4. 程序4-4 chmod函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  5. 程序4-3 umask函数实例

    //http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...

  6. linux C函数之access函数的用法

    1.函数功能: 检查调用进程是否可以对指定的文件执行某种操作. 2.函数原型: 1)函数头文件 #include <stdio.h> #include <unistd.h> 2 ...

  7. python迭代器与iter()函数实例教程

    python迭代器与iter()函数实例教程 发布时间:2014-07-16编辑:脚本学堂 本文介绍了python迭代器与iter()函数的用法,Python 的迭代无缝地支持序列对象,而且它还允许程 ...

  8. 文件和目录:access函数

    access函数是按照实际用户ID和实际组ID进行访问权限测试的: #include <unistd.h> int access( const char *pathname, int mo ...

  9. 解决C#程序只允许运行一个实例的几种方法详解

    解决C#程序只允许运行一个实例的几种方法详解 本篇文章是对C#中程序只允许运行一个实例的几种方法进行了详细的分析介绍,需要的朋友参考下 本文和大家讲一下如何使用C#来创建系统中只能有该程序的一个实例运 ...

随机推荐

  1. 逆序对算法(reverse pair)

    逆序对(reverse-pair) 思想和归并排序的思想一样,时间复杂度是O(nlgn). 就是在统计逆序对个数的表达式需要注意一下. 具体实现 #include <iostream> # ...

  2. hive 数据清理--数据去重

    hive> select * from (select *,row_number() over (partition by id) num from t_link) t where t.num= ...

  3. 关于setTimeout()你所不知道的地方,详解setTimeout()

    关于setTimeout()你所不知道的地方,详解setTimeout() 前言:看了这篇文章,1.注意setTimeout引用的是全部变量还是局部变量了,当直接调用外部函数方法时,实际上函数内部的变 ...

  4. ASC和字符转化,整形和String转化

    public class ASCTest { public static void main(String[] args) { /* 区别这两种 String s = "123"; ...

  5. Ajax的跨域问题(包括解决方案)?

    原因:js的同源策略限制,不同源会造成跨域 哪些情况会造成跨域? 子域名不同(WWW) 2.主域名不同(baidu.com) 3.端口号不同 4.IP地址和网址不同 解决方案: 使用jsonp技术,但 ...

  6. SVN与Git优缺点比较

    1.SVN优缺点优点: 1. 管理方便,逻辑明确,符合一般人思维习惯. 2. 易于管理,集中式服务器更能保证安全性. 3. 代码一致性非常高. 4. 适合开发人数不多的项目开发. 缺点: 1. 服务器 ...

  7. 关于微软C#中的CHART图表控件的简单使用

    最近公司项目要用到Chart图表控件,这是一个比较老的东西了,目前网络上似乎已经不太流行这个控件,但是只要配置了相关的属性,效果还是可以的.前前后后摸索了好久,接下来谈谈这个件控件最重要的几个属性. ...

  8. LeetCode OJ:Search Insert Position(查找插入位置)

    Given a sorted array and a target value, return the index if the target is found. If not, return the ...

  9. 谈一下思考,关于mybatis中<foreach collection="list">中list得来的原因 没看到官方说明

    <foreach> 是在sql语句中进行多个id查询 时用到的,因为mybatis代替jdbc和hibernate, 使用 在xml文件中编写sql语句,这是一个标签文件.然后在 dao层 ...

  10. Qt5学习笔记——QRadioButton与QbuttonGroup

    [我是小标题:使用QToolButton实现radio button功能.] QRadioButton是什么?  下图是Windows系统中典型的radio button显示效果.    QRadio ...