7.11 open Function
Open a file.
Include
None
Prototype
int open(const char *name, int access, int
mode);
Arguments
name
- name of the file to be opened
access
- access method to open file
mode
- type of access permitted
Return Value
If successful, the function returns a file handle: a small positive integer. This handle
is then used on subsequent low-level file I/O operations. A return value of -1 indicates
an error, and the global variable errno
is set to the value of the
symbolic constant, EFOPEN
, defined in
<errno.h>
.
Remarks
This function is implemented as a stub that must be completed to suit the application.
This helper function is called by the Standard C Library functions
fopen()
and freopen()
.
- 0 – Open a file for reading.
- 1 – Open a file for writing.
- 2 – Open a file for both reading and writing.
- 0x0008 – Move file pointer to end-of-file before every write operation.
- 0x0100 – Create and open a new file for writing.
- 0x0200 – Open the file and truncate it to zero length.
- 0x4000 – Open the file in text (translated) mode.
- 0x8000 – Open the file in binary (untranslated) mode.
- 0x0100 – Reading only permitted.
- 0x0080 – Writing permitted (implies reading permitted).
Default Behavior
As distributed, the parameters are passed to the host file system through the simulator. The return value is the value returned by the host file system.
Source File
open.c