Skip to main content

IAR Embedded Workbench for RH850 3.20.x

__openFile

In this section:
Syntax
__openFile(filename, access)
Parameters
filename

The file to be opened. The filename must include a path, which must either be absolute or use argument variables. For information about argument variables, see Argument variables.

access

The access type (string).

These are mandatory but mutually exclusive:

"a" append, new data will be appended at the end of the open file

"r" read (by default in text mode; combine with b for binary mode: rb)

"w" write (by default in text mode; combine with b for binary mode: wb)

These are optional and mutually exclusive:

"b" binary, opens the file in binary mode

"t" ASCII text, opens the file in text mode

This access type is optional:

"+" together with r, w, or a; r+ or w+ is read and write, while a+ is read and append

Return value

Result

Value

Successful

The file handle

Unsuccessful

An invalid file handle, which tests as False

Table 36. __openFile return values 


For use with

All C-SPY drivers.

Description

Opens a file for I/O operations. The default base directory of this macro is where the currently open project file (*.ewp) is located. The argument to __openFile can specify a location relative to this directory. In addition, you can use argument variables such as $PROJ_DIR$ and $TOOLKIT_DIR$ in the path argument.

Example
__var myFileHandle;         /* The macro variable to contain */
                            /* the file handle */
myFileHandle = __openFile("$PROJ_DIR$\\Debug\\Exe\\test.tst", "r");
if (myFileHandle)
{
    /* successful opening */
}
See also

For information about argument variables, see the IDE Project Management and Building documentation.