194
"C" Programming Guide For Optimus S/R
Error Code
Interpretation
2
File specified by
fd
does not exist.
4
File specified by
fd
is not a DAT file.
7
Invalid file handle.
8
File not opened.
9
Invalid value in argument:
origin
15
New position is beyond end-of-file.
See Also
tell
open
Purpose
To open a DAT file and get its file handle for further processing.
Syntax
int open (char *filename);
char *filename; /* name of the file to be opened */
Example
if (fd = open ("data1" > 0) puts ("data 1 is opened!\n");
Description
This routine opens a DAT file (
filename
) and gets the file handle of it.
A file handle is a positive integer (greater than zero) used to identify the
file for subsequent file manipulation on the file.
If the file specified by
filename
does not exist, it will be created first.
If
filename
exceeds eight characters, it will be truncated to eight
characters.
After the file is opened, the file pointer points to the beginning of file.
Return
If successful, it returns the file handle.
On error, it returns -1.
An error code is set to the global variable fErrorCode to indicate the error
condition encountered. Below are possible error codes and their interpretation.
Error Code
Interpretation
1
filename
is a NULL string.
4
File specified by
filename
is not a DAT file.
5
File specified by
filename
is already opened.
6
Cannot create file. Because it is beyond the
maximum number of files allowed in the
system.
See Also
close
Summary of Contents for Optimus R
Page 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Page 6: ......
Page 8: ...2 C Programming Guide For Optimus S R...
Page 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Page 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Page 24: ...18 C Programming Guide For Optimus S R...
Page 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...