open是一个非标准的低级文件I/O函数,返回的是文件的低级句柄,原型:
int open(char* path, int access, ...);
open是一个可变参数的函数实现,后面的可变参数通常表示unsigned mode,mode参数是否存在要看access的值,path是文件的路径。
access和mode的可取值通常在FCNTL.h里面定义,access的可取值如下:
#define O_RDONLY 1
#define O_WRONLY 2
#define O_RDWR 4
access还可以是以下flag及它们之间的组合而得到的性质:
#define O_CREAT 0x0100 /* create and open file */
#define O_TRUNC 0x0200 /* open with truncation */
#define O_EXCL 0x0400 /* exclusive open */
#define O_APPEND 0x0800 /* to end of file */
#define O_CHANGED 0x1000 /* user may read these bits, but */
#define O_DEVICE 0x2000 /* only RTL/io functions may touch. */
#define O_TEXT 0x4000 /* CR-LF translation *