Opens a file and prepares it for subsequent reading or writing.
#include <fcntl.h> #include <sys/stat.h> #include <io.h> int open(const char *filename, int oflag [, int pmode]);
filename
oflag
oflag | Description |
---|---|
O_BINARY |
Open the file in binary mode. Without this flag the file is opened in ASCII mode. |
O_TEXT |
Open the file in ASCII mode (the default mode). In this mode end-of-line sequences are translated and the end-of-file character CTRL-Z is recognized. |
O_WTEXT |
Open the file in wide-character text mode. In this mode end-of-line sequences are translated and the end-of-file character CTRL-Z is recognized. |
O_CREAT |
If this flag is specified an attempt is made to create the file. If the file does not exist then it is created. If the file does exist then the call fails unless the O_TRUNC falg is also given. |
O_TRUNC |
The file is truncated after opening. If combined with O_CREAT then an existing file may be opened and then truncated. |
O_APPEND |
The file pointer is moved to the end of the file after opening. |
O_EXCL |
The file is opened with exclusive (i.e. not shared) access. |
pmode
The open function applies the default file-permission mask set with umask to pmode before setting the permissions.
By default, this function creates files that all threads can share. If O_EXCL is OR-ed with pmode, the file is opened with share-with-none permission.
EACCES | Given pathname is a directory; or an attempt was made to open a read-only file for writing; or a sharing violation occurred (the file's share mode does not allow the specified operations). |
EEXIST | The O_CREAT and O_EXCL flags are specified, but the named file already exists. |
EINVAL | An invalid oflag or pmode argument was given. |
EMFILE | No more file descriptors available (too many open files). |
ENOENT | File or pathname not found. |
Versions | Defined in | Include | Link to |
---|---|---|---|
INtime 3.0 INtime 6.0 (for wide-character support) |
intime/rt/include/io.h intime/rt/include/fcntl.h (for oflag definitions) |
fcntl.h sys/stat.h io.h |
clib.lib |