-
Notifications
You must be signed in to change notification settings - Fork 54
open
果冻虾仁 edited this page Mar 25, 2015
·
11 revisions
基于文件描述符的文件打开方式 ###函数原型
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int open(const char* pathname,int flags);
int open(const char* pathname,int flags,mode_t mode);
int creat(const char* pathname,mode_t mode);
stat是status的缩写
fcntl是file control的缩写
##参数
###flags
flags字段使用POSIX的几个宏,此时必须包含头文件<fcntl.h>
才行。
Talk is cheap, show me the code!
C语言API包含部分
标准C的API、POSIX标准的系统编程API(一些Linux独有的系统API会单独注明)。
大部分头文件源码在/usr/include
目录下。
因为涉及到大量的POSIX编程。所以最好下载POSIX函数的man手册。
apt-get install manpages-posix
apt-get install manpages-posix-dev
默认安装了manpages-dev
,所以不装POSIX的man手册是可以查看绝大部分API的。
但是不装的话,有些API是不能看到的,比如posix_spawn
函数。
yum install man-pages.noarch
关于目录
左侧的目录并非以函数为索引依据,主要是以系统的man手册页面为索引依据。
比如exec里面包含6个函数、pipe里面包含pipe()和pipe2()两个函数,但是它们都是属于一个man页面中。