Open is a non-standard low-level file I/O function that returns a lower-level handle to the file, prototype:
int open (char* path, int access, ...). );
Open is a function implementation of a variable parameter, and the following variable parameter usually indicates whether the unsigned Mode,mode parameter exists to see the value of access, and path is the file.
The desirable values for access and mode are usually defined in FCNTL.h, and access's desirable values are as follows:
#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 */
#define O_BINARY 0x8000 /* no translation */
When using O_creat, you must specify the mode parameter, and the value of mode is defined in the sys\stat.h, or it can be a combination of the following:
#define S_IREAD 0x0100 /* owner may read */
#define S_IWRITE 0x0080 /* owner may write */