188
"C" Programming Guide For Optimus S/R
3.14.6 DAT Files
DAT files have a sequential file structure.
Data at the beginning of a DAT file can be removed by calling the
delete_top()
or
delete_topln()
function. The new file top, the file pointer, and the size of the DAT file will be
adjusted accordingly after calling either of the two functions.
The
append()
and
appendln()
functions can write data to the EOF (end of file) position, no
matter where the file pointer points to. That is, the file pointer position is not changed after
calling these functions.
Normally, this is the scheme for handling the transaction data, that is, reading and removing
data from top of the file, and adding new data to the bottom of a file.
append
Purpose
To write a specified number of bytes to the bottom (EOF) of a DAT file.
Syntax
int append (int fd, char *buffer, int count);
int fd; /* file handle of the target DAT file */
char *buffer; /* pointer to a buffer where data is written to */
int count; /* number of bytes to be written */
Example
append (fd, "1234567890", 10);
Description
This routine writes a number of bytes (
count
) from the character array
buffer
to
the bottom of a DAT file (
fd
).
Writing of data starts at the end-of-file position, and the file pointer
position is unaffected by the operation.
This routine will automatically extend the file size to hold the data written.
The maximum number of characters that can be written is 32767.
Return
If successful, it returns the number of bytes actually written to the file.
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
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.
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...